I’m working on a http request. I've faced problem previously which my object shows [object promise] in the URL request. So i had await the return of the Promise of the object which is my user variable.
But I'm now getting an error
Property 'subscribe' does not exist on type
Promise<Observable<any>>.
I also googled this and have done necessary changes but the outcome is the same.
this is my code of the http request:
async getUserFromStorage():Promise<any>{
return await this.storage.get('currentUser');
}
async getUserOrder()
{
const user = await this.getUserFromStorage();
var url="https://localhost:44399/api/APIOrder/GetUserOrder?email=";
console.log(url+user);
return this.http.get(url+user).map(res=>res.json());
}
This is the code which is failing:
public getOrders(){
this.getUserOrder()
.subscribe(data =>{ //HERE
for(var i=0;i<data.length;i++)
{
this.orders.push(data[i]);
}
})
return this.orders;
}