Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLSearchParams in body doesn't set content-type to x-www-form-urlencoded #186

Open
zmeyc opened this issue Nov 16, 2019 · 0 comments
Open

Comments

@zmeyc
Copy link

zmeyc commented Nov 16, 2019

Using URLSearchParams() as body doesn't set content-type to application/x-www-form-urlencoded. https://fetch.spec.whatwg.org section 5.2

  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.

'content-type': 'application/x-www-form-urlencoded; charset=utf-8'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant