Skip to content

Instantly share code, notes, and snippets.

@desoga10
Created March 20, 2023 01:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save desoga10/91f9c863016531d4ce946926ccd04f91 to your computer and use it in GitHub Desktop.
Save desoga10/91f9c863016531d4ce946926ccd04f91 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { environment } from 'src/environments/environment';
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'X-My-Custom-Header': `${environment.API_KEY}`,
'Access-Control-Allow-Origin': '*',
}),
};
@Injectable({
providedIn: 'root',
})
export class ChartService {
private baseUrl = 'https://api.coinranking.com/v2/coins';
private proxyUrl = 'https://cors-anywhere.herokuapp.com/';
constructor(private http: HttpClient) {}
cryptoData() {
const url = `${this.proxyUrl}${this.baseUrl}`;
return this.http.get(url, httpOptions);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment