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

Bug: Post helper squashes data into fetch options #494

Open
mismith opened this issue Nov 29, 2024 · 4 comments
Open

Bug: Post helper squashes data into fetch options #494

mismith opened this issue Nov 29, 2024 · 4 comments

Comments

@mismith
Copy link

mismith commented Nov 29, 2024

This simple request:

const fetchClient = mande('/api/some-url');
await fetchClient.post({ priority: 99 });

Throw this error:
image

Reproduction: https://stackblitz.com/edit/vitejs-vite-rdwntz?file=src%2Fmain.js

Looks like the payload that's intended to be data is being passes to fetch directly/outside of a stringified JSON body.

@mismith
Copy link
Author

mismith commented Nov 29, 2024

Potential fix here: #495

@posva
Copy link
Owner

posva commented Nov 30, 2024

Thanks for the PR, you need to pass a first argument for data: await fetchClient.post({}, { priority: 30 });

@posva posva closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2024
@mismith
Copy link
Author

mismith commented Nov 30, 2024

@posva Are you sure? The workaround I shipped was
await fetchClient.post({ priority: 99 }, {});
but
await fetchClient.post({}, { priority: 99 });
suggest to me that the data would be empty and the options would have priority set, no? When I test it, it still fails.

At any rate, it seems like a logical error anyway, no? Why would you ever want data to 'leak' into the fetch options?

Copy link
Owner

posva commented Nov 30, 2024

Oh yeah, I thought you wanted to pass the option, I misread

@posva posva reopened this Nov 30, 2024
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