Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axios vs Request

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.

like image 423
Rohit Kumar Avatar asked Oct 14 '17 21:10

Rohit Kumar


1 Answers

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.

like image 116
glhrmv Avatar answered Oct 07 '22 14:10

glhrmv