I have to make a post request to an API endpoint and it is required that the body of the request is encoded in application/x-www-form-urlencoded.
Here is what I am currently doing:
// Request data const data = { grant_type: "client_credentials", }; // Request configuration const config = { method: "post", url, data, headers: { "Content-Type": "application/x-www-form-urlencoded", Authorization: "Basic " + Buffer.from(clientId + ":" + clientSecret).toString("base64"), }, }; return axios(config).then(..... As you can see, I have my data in JSON format, so how can I pass it encoded in application/x-www-form-urlencoded?
Any ideas? Thank you.