cic-staff-client/src/app/_services/token.service.ts

27 lines
748 B
TypeScript

import { Injectable } from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {environment} from '@src/environments/environment';
import {first} from 'rxjs/operators';
import {BehaviorSubject} from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class TokenService {
tokens: any = '';
private tokensList = new BehaviorSubject<any>(this.tokens);
tokensSubject = this.tokensList.asObservable();
constructor(
private http: HttpClient
) { }
getTokens(): any {
this.http.get(`${environment.cicCacheUrl}/tokens`).pipe(first()).subscribe(tokens => this.tokensList.next(tokens));
}
getTokenBySymbol(symbol: string): any {
return this.http.get(`${environment.cicCacheUrl}/tokens/${symbol}`);
}
}