I'd like to get Object
using Promise
.
Bellow, is the method:
async getUri()
{
var data = this.userService.getOrders();
var outside_uri = await data.then((uri) => { console.log('inside => ' + uri); return uri;})
console.log('outside => ' + outside_uri)
}
where
getOrders(): Promise<Profession[]>
{
return this.http.get<Profession[]>(`${this.baseUrl}/users/professions/id/2`)
.toPromise()
.then((response) => response);
}
But when I call this method on ngOnInit() like that:
console.log("-----Result: " + this.getUri());
It produces:
-----Result: [object Promise]
inside => [object Object]
outside => [object Object]
Have you please any idea about solving that ?. Big Thanks.