I need to pass two parameters to my end point, along with the request so that would make it three and only two are allowed per my http post request. I tried the HttpParams but that does not work in my case. The situation is when product is chosen a size must be chosen as well. It works when I add url plus end point and append the Id. I then add Id to my end point, I have already tested it, product is added to cart. There are different sizes for each product so a size must me chosen. Once I get the issue with the parameter figured out I will update the item by Id this is the reason I need both parameters. I can’t append the size and Id I will get an error.
I Need figure out the best approach to get both. Everything I had tried does not work.
Can someone point me in the right direction: Code snippet below:
cart Service:
addProductToCart(product:Product, _id:String, size:String):Observable<Product>{
return this.http.post<Product>(this.rootUrl + '/getProducts/addtocart' + _id,
{product})
}
api:
router.post('/getProducts/addtocart:_id', async(req, res)=> {
.......
}) //this works
update service:
UpdateCart(product:Product, _id:String, size:String):Observable<Product>{
alert("Service update cart")
return this.http.post<Product>(this.rootUrl + '/getProducts/updatecart/' + _id +
size, {product})
}
api end point:
router.post('/getProducts/updatecart/:_id/:size', async(req,res)=>{
const _id = req.params.id;
const size = req.params.size;
}); //The above does not work gives me an error