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

Post requests with tag arrays are not working. #20

Closed
nim1821 opened this issue Feb 3, 2019 · 4 comments · Fixed by #21
Closed

Post requests with tag arrays are not working. #20

nim1821 opened this issue Feb 3, 2019 · 4 comments · Fixed by #21
Assignees

Comments

@nim1821
Copy link
Collaborator

nim1821 commented Feb 3, 2019

To my understanding, vue-resource's http.post method adds unwanted [] at every tag.

@imarmanis
Copy link
Owner

This seems to be the default behavior of both axios and resource.
If we switch to axios ( + qs ) we could resolve it with :
axios.defaults.paramsSerializer = (params) => { return qs.stringify(params, {arrayFormat: 'repeat'}) }

@nim1821
Copy link
Collaborator Author

nim1821 commented Feb 3, 2019

https://craftcms.stackexchange.com/questions/19061/updating-a-user-on-the-front-end-with-vue-js-and-axios

apparently, axios does not have an "emulateJSON" option, making it even harder to send it as form data in the first place...

@nim1821
Copy link
Collaborator Author

nim1821 commented Feb 3, 2019

Nevermind the {arrayFormat: 'repeat'} option resolves all issues...

Fixing. Suggested solution works like a charm :D

@nim1821 nim1821 self-assigned this Feb 3, 2019
@nim1821 nim1821 reopened this Feb 4, 2019
@nim1821
Copy link
Collaborator Author

nim1821 commented Feb 4, 2019

Unless we find some better way we will have to switch to using axios every time we wish to send tags.

Axios cannot be used everywhere because its default setting cannot be set to urlencoded form data.

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