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

Spreading file upload (multipart) payload in axios doesn't work #108

Open
sanjarcode opened this issue Dec 29, 2023 · 1 comment
Open

Spreading file upload (multipart) payload in axios doesn't work #108

sanjarcode opened this issue Dec 29, 2023 · 1 comment
Assignees

Comments

@sanjarcode
Copy link
Member

sanjarcode commented Dec 29, 2023

const id, params, payload;
axios.put(`/vendors/${id}`, { ...payload, id }, { params }); // won't work
axios.put(`/vendors/${id}`, payload, { params: { ...params, id } }); // works, of course BE is RoR so values can be passed in body or query param

Find a fix.

@sanjarcode sanjarcode self-assigned this Dec 29, 2023
@sanjarcode
Copy link
Member Author

Not an axios issue. Payload should either be string (JSON.stringify) or FormData, can't be a mix. Axios accepts objects, but again, if FormData is involved, make sure it's passed as is as second param

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