Add stock data api call
This commit is contained in:
parent
95a524dd04
commit
9aa45d28d8
@ -12,21 +12,27 @@ export class DataService {
|
|||||||
private tokenStorage: TokenStorageService
|
private tokenStorage: TokenStorageService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
httpOptions = {
|
headers = new HttpHeaders({
|
||||||
headers: new HttpHeaders({
|
'Content-Type': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
Authorization: 'Bearer ' + this.tokenStorage.getToken(),
|
||||||
Authorization: 'Bearer' + this.tokenStorage.getToken(),
|
});
|
||||||
}),
|
|
||||||
};
|
|
||||||
|
|
||||||
getStockData(): Observable<any> {
|
async getStockData() {
|
||||||
return this.http.get(API_URL + 'portfolio', {
|
await this.http
|
||||||
headers: this.httpOptions.headers,
|
.get(API_URL + 'portfolio', {
|
||||||
|
headers: this.headers,
|
||||||
|
responseType: 'text',
|
||||||
|
})
|
||||||
|
.subscribe((data) => {
|
||||||
|
console.log(data);
|
||||||
|
return data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getKeywords(): Observable<any> {
|
||||||
|
return this.http.get(API_URL + 'keywords', {
|
||||||
|
headers: this.headers,
|
||||||
responseType: 'text',
|
responseType: 'text',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showStorage() {
|
|
||||||
console.log(localStorage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { throwToolbarMixedModesError } from '@angular/material/toolbar';
|
||||||
|
import { DataService } from 'src/app/Services/data.service';
|
||||||
|
|
||||||
export interface PeriodicElement {
|
export interface PeriodicElement {
|
||||||
name: string;
|
name: string;
|
||||||
@ -46,9 +48,11 @@ const ELEMENT_DATA: PeriodicElement[] = [
|
|||||||
styleUrls: ['./dashboard.component.scss'],
|
styleUrls: ['./dashboard.component.scss'],
|
||||||
})
|
})
|
||||||
export class DashboardComponent implements OnInit {
|
export class DashboardComponent implements OnInit {
|
||||||
constructor() {}
|
constructor(private dataService: DataService) {}
|
||||||
|
|
||||||
ngOnInit(): void {}
|
async ngOnInit() {
|
||||||
|
const data = await this.dataService.getStockData();
|
||||||
|
}
|
||||||
|
|
||||||
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
|
displayedColumns: string[] = ['position', 'name', 'weight', 'symbol'];
|
||||||
dataSource = ELEMENT_DATA;
|
dataSource = ELEMENT_DATA;
|
||||||
|
Loading…
Reference in New Issue
Block a user