Reputation: 21
I'm trying to pull data from coin gecko api, but I'm getting status 404 error and the body is returning error: "Collection 'v3' not found". The api url I'm using is https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd.
I'm working with Angular and using an https.get request.
This is my service class
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'my-auth-token'
})
};
constructor(private http: HttpClient) { }
api: string = 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd';
getCoinData(): Observable<Coin[]> {
return this.http.get<Coin[]>(this.api, httpOptions);
}
This is my component ts file
constructor(private cryptoCoinService : CryptoCoinsService) { }
ngOnInit(): void {
this.getTopCoins();
}
getTopCoins() {
this.cryptoCoinService.getCoinData()
.subscribe(data => {
this.topCoins = data;
},
err => console.log(err));
}
It should return
{
"bitcoin": {
"usd": 17274.17
}
}
Upvotes: 0
Views: 330
Reputation: 21
Thanks for the responses. I figured it out I forgot I was using InMemoryDataService from earlier when I was testing some stuff, I just had to comment those parts out.
Upvotes: 0