I am doing a post request to an URL with some formdata.... I am interested in capturing the "command":"insert" part which is in the response..
when I make a post to an url using AXIOS. I dont get this "command":"insert" part
axios.post('https://www.localgov.ie/en/views/ajax', {
validation_date_from: "10/10/2017",
view_name : "bcsm_search_results",
view_display_id : "notice_search_pane",
view_path : "bcms/search"
}).then(function(response){
console.log( response.data)
console.log("--------------------------------AXIOS POST")
})
but when I make a call to the same URL using the same form variables BUT using request. I get the "command":"insert" part
var formdata ={
validation_date_from: "10/10/2017",
view_name : "bcsm_search_results",
view_display_id : "notice_search_pane",
view_path : "bcms/search"
} ;
request.post({
url: 'https://www.localgov.ie/en/views/ajax',
form: formdata
},
function (err, httpResponse, body) {
console.log(body);
console.log("--------------------------------request POST")
});
Here is a demo I have put on RequireBin.. Kindly run on mozilla or Cors disabled Chrome.
This seems to be an issue with axios' handling of POST requests with Content-Type: application/x-www-form-urlencoded
. There is an open issue that offers some discussion and possible workarounds in axios' GitHub page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With