I'm having trouble making a function that returns the data "array" that I want to consume using a Promise. The tech stack that I'm using is Angular, Typescript and Express.js. I can get the data to return inside of the getData() function however, the data is not passed on in the return statement, I just get an empty array in ngOnInit();
getData Function:
public async getData(user: any): Promise<any> {
this._url = 'http://localhost:5000/account/data';
const data = this._http.post<any>(this._url, user).toPromise();
return data
}
ngOnInit:
ngOnInit(): void {
this._account.getData(this.login)
.then((data: any) => {
console.log(data)
});
}
result = [ ];