Cross-domain request method of axios


Created: Sunday, April 15, 2018 2:52 PM | Category: Uncategorized | Word Count: 552  | Save As... | Print | Add to Calendar             
 axios({
     headers: {
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'application/json; charset=UTF-8',
'Access-Control-Allow-Origin': '*'
},//Set the cross-domain request header
    method: "POST",//Request method
      data: {
 "menu_id":1,
"thirdapp_id":1//Request parameters

      }
    })
      .then(function(res) {
        //return value
        console.log(res.data);
        for(var i=0;i<res.data.length;i++){
          console.log(res.data[i].name)
        }
      })
      .catch(function(err) {
        console.log(err);
      });

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324838699&siteId=291194637