Open zmeyc opened 4 years ago
Using URLSearchParams() as body doesn't set content-type to application/x-www-form-urlencoded. https://fetch.spec.whatwg.org section 5.2
application/x-www-form-urlencoded
const body = new URLSearchParams({ grant_type: 'client_credentials' }) fetch(url, { method: 'POST', headers: { 'accept': 'application/json', }, body: body})
A workaround is to pass it explicitly. node-fetch package works as expected.
node-fetch
'content-type': 'application/x-www-form-urlencoded; charset=utf-8'
Using URLSearchParams() as body doesn't set content-type to
application/x-www-form-urlencoded
. https://fetch.spec.whatwg.org section 5.2A workaround is to pass it explicitly.
node-fetch
package works as expected.