Created
March 20, 2023 01:49
-
-
Save desoga10/91f9c863016531d4ce946926ccd04f91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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