- App to get crypto currency price data from a CryptoCompare API.
- Code from Gary Simon at DesignCourse - see 👏 Inspiration below.
- Note: to open web links in a new window use: ctrl+click on link
- Angular httpClient used to get API data
- Data displayed using one-way data-binding and an *ngFor loop
- Separate
data.service.ts
file used to get API price data. This data is subscribed to inapp.component.ts
- Angular v13
- RxJS Library v7 used to subscribe to the observable
- Install dependencies using
npm i
. - Run
ng serve
for a dev server. Navigate tohttp://localhost:4200/
. The app will automatically reload if you change any of the source files.
data.service.ts
using httpClient service with agetPrices()
function to get crypto currency details from the API.
@Injectable()
export class DataService {
result: any;
currencyCode: string;
display: string;
constructor(private http: HttpClient) {}
// function to get crypto prices in euro from the API - no API key required.
getPrices() {
const fsymsList =
"BTC,XRP,BCH,ETH,ZEC,EOS,XMR,ETC,LTC,DASH,QTUM,NEO,XLM,TRX,ADA,BTS,USDT,XUC,PAX,IOT";
return this.http
.get(
"https://min-api.cryptocompare.com/data/pricemulti?fsyms=" +
fsymsList +
"&tsyms=EUR"
)
.pipe(map((result) => (this.result = result)));
}
}
- Angular httpClient used to get data from an external API.
- Angular currency pipe & rxjs map operator used to extract currency data and display it to the correct format.
- Dependencies updated with 0 dependency vulnerabilities.
- Status: Working
- To-Do: Nothing
- This project is licensed under the terms of the MIT license.
- Repo created by ABateman, email: gomezbateman@yahoo.com