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

JSON headers is not working for array of objects #28

Closed
Narixius opened this issue Nov 16, 2021 · 0 comments · Fixed by #29
Closed

JSON headers is not working for array of objects #28

Narixius opened this issue Nov 16, 2021 · 0 comments · Fixed by #29

Comments

@Narixius
Copy link
Contributor

Narixius commented Nov 16, 2021

Hi there.
I was working with this library and I found out in a special case, it doesn't add header content-type: application/json to the request.

What I did

$fetch("/api/endpoint", {method: "POST", body: [{num: 42}, {num: 43}]})

What I expected

Automatically add content-type: application/json header and stringify the body.

What actually happened

the content-type: application/json header was not added and the request body replaced with [object Object],[object Object]

Details

The request was not contain content-type: application/json header because as this feature implemented here, the toString() of the body in this case is not equal to [object Object] (actually it is equal to [object Object],[object Object] in this case). So automatic json headers and body stringify didn't happen.

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

Successfully merging a pull request may close this issue.

1 participant