PUT and PATCH sending application/x-www-form-urlencoded data
See original GitHub issueUsing 0.5.4
I’m trying to use axios on my front end and fuel on the backend. Fuel Input::patch(‘param’) will give me data from the form request of type patch. This is also true for PUT. Perhaps also POST a.s.o.
When I use axios the data is empty and if I use jquery I get my data just fine.
$.ajax({
method: "PATCH",
url: URL,
data: {
'firstname': this.state.account.firstname,
'surname': this.state.account.surname,
}
})
.done(function( msg ) {
console.log(msg);
});
axios.patch(URL, {
'firstname': this.state.account.firstname,
'surname': this.state.account.surname,
})
.then((response) => {
console.log(response);
});
The difference is if you look at chrome developer tools that jquery sends the data as formData and axios sends the data as json request payload.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:13
- Comments:36 (3 by maintainers)
Top Results From Across the Web
Can HTTP PUT request have application/x-www-form ...
Yes you can use application/x-www-form-urlencoded with PUT. The HTTP spec does not limit what methods can be used with what media types.
Read more >Retrofit — Send Data Form-Urlencoded - Future Studio
You may already know how to send data within the request body or how to make use of multipart/form-data to upload files using...
Read more >POST, PUT & PATCH Requests with VueJS and Axios
A quick overview on how to submit form data securely to an API ... to the server is through JSON and application/x-www-form-urlencoded ....
Read more >POST - HTTP - MDN Web Docs
The HTTP POST method sends data to the server. ... application/x-www-form-urlencoded : the keys and values are encoded in key-value tuples ...
Read more >Passing “x-www-form-urlencoded” body format data in REST ...
First let us try to see how we pass “x-www-form-urlencoded” ... Also choose the type of operation (GET/POST/PATCH/PUT) as per the guidelines ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
How about axios including the above-mentioned serialization code so a
Content-Type
ofapplication/x-www-form-urlencoded
triggers the right encoding when an object is passed?… should work out of the box IMHO. Or do I miss something?
axios v0.12.0 supports URLSearchParams which can be used to send the data as application/x-www-form-urlencoded from the browser:
Please note that
URLSearchParams
is not supported by all browsers, so you may need to polyfill it. (Make sure to add the polyfill to the global scope.)