Both foo() and addProduct() are methods of same class. addProduct() gets called when a form it's submitted. I was expecting to be displayed first "ok1" and then "ok2" inside Console but it's happening otherwise. I'm doing something wrong?
async foo(url, obj) {
const result = await this.http.post(url, obj).toPromise();
return result;
}
addProduct(ProductName, ProductDescription, ProductPrice) {
const obj = {
ProductName,
ProductDescription,
ProductPrice
};
this.foo("http://localhost:4000/products/add", obj).then( (result) => {
console.log("ok1");
});
console.log("ok2");
}