0

PUTパスにパラメータを送信するリクエストの書き方を知りたいです。たとえば、dev は PUT 要求の URL を、クエリ文字列をパラメーターとして使用することから、パス内のパラメーターを使用するように変更しました。パラメータがクエリとして送信されたとき、私は次のようなことをしました:

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

return this._$q((resolve, reject) => {
   this._$http.put(‘/api/products/customer/mostRecent’, payload)
   .then((result) => resolve(result))
   .catch((err) => {
      reject(…));
   });
});

簡単。

ただし、パスで params を使用するように PUT リクエストが変更されたため、次のようになります。

PUT api/products/customer/{customerId}/product/{productId}

私はそれをどのように正確に書くでしょうか?

let customer_id = this.customerId,
    product_id = this.productId;

let payload = {
    user_GuideId: this.userGuideId
}

this._$http.put(“api/products/”+customer_id+“/product/”+product_id, payload);

これを行う方法がわからないため、上記はおそらく間違っています。答えてくれてありがとう。ありがとう。

4

1 に答える 1