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

[useFetch] Headers cannot be a Headers object #625

Closed
glen-84 opened this issue Jul 15, 2021 · 0 comments · Fixed by #631
Closed

[useFetch] Headers cannot be a Headers object #625

glen-84 opened this issue Jul 15, 2021 · 0 comments · Fixed by #631
Assignees

Comments

@glen-84
Copy link
Contributor

glen-84 commented Jul 15, 2021

Works:

const {data} = useFetch("/page", {headers: {Accept: "application/json"}}).json();

Doesn't:

const headers = new Headers();
headers.append("Accept", "application/json");

const {data} = useFetch("/page", {headers}).json();

I think it's caused by the spreading here:

headers: {
...(fetchOptions.headers || {}),
...(args[0].headers || {}),
},

And here:

headers: {
...defaultFetchOptions.headers,
...context.options?.headers,
},

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.

2 participants