I have a post request where i need to send x-www-form-urlencoded keyValue pair parameters and content-type should be x-www-form-urlencoded.Here,I am sending Json as a body.I just wanna know how to send this in body and call it in cart function
url: http://something/carts/{cart_id}
postman form body = {id}: {value}
static post(url, headers, body, resolve, reject) {
fetch(`${this.data}${url}`, {
headers: headers,
method: 'POST',
body: JSON.stringify(body)
})
.then((resp) => {
resolve(resp.json());
})
.catch(err => reject(err))
}
static Cart(id, product_id) {
return new Promise((resolve, reject) => {
this.post(`/carts/${cart_id}${product_id}`, {
//Does this url correct.
"Content-Type": "application/x-www-form-urlencoded",
"X-Authorization": this.authorization_key
}, resolve, reject)
})
}