Skip to content

Instantly share code, notes, and snippets.

@Ruivilela
Created January 9, 2017 18:16
Show Gist options
  • Save Ruivilela/b8de26425d40c2e62ccf56fb1d43aae8 to your computer and use it in GitHub Desktop.
Save Ruivilela/b8de26425d40c2e62ccf56fb1d43aae8 to your computer and use it in GitHub Desktop.
@Injectable()
export class PokedexService {
private baseUrl: string ='https://pokeapi.co/api/v2/';
constructor(private http: Http) { }
getPokemon(index:number) : Observable<Pokemon> {
return this.http.get(`${this.baseUrl}pokemon/${index}`)
.map((result:Response) => result.json())
.map((res) => {return new Pokemon(index, res.name, res.sprites.front_default)})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment