Skip to content Skip to sidebar Skip to footer

How To Use Path Parameters In Http.put Request

I want to know how to write the PUT request that sends parameters in the path. For example, dev changed the URL for the PUT request from a using a query string as parameters to usi

Solution 1:

You can do something like this:

this._$http.put(`api/products${customerId}/product/${productId}`, payload);

Note: I am using Template literals: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

Thank you!

Updated:

let payload = {
   product_id: this.productId,
   customer_id: this.customerId,
   userGuide_id: this.userGuide
}

returnthis._$q((resolve, reject) => {
   this._$http.put(`api/products${payload.customer_id}/product/${payload.product_id}`, payload);
   .then((result) =>resolve(result))
   .catch((err) => {
      reject(…));
   });
});

Post a Comment for "How To Use Path Parameters In Http.put Request"