Axios发送Ajax请求


axios.html

  • get
  • post
  • 通用




  
  axios发送ajax请求
  



  
  
  
  
  



server.js

//axios服务
app.all('/axios-server', (request, response) => {
  //设置响应头 设置允许跨域
  response.setHeader('Access-Control-Allow-Origin', '*');
  response.setHeader('Access-Control-Allow-Headers', '*')
  //设置响应体
  // response.send('Hello Axios Ajax');
  const data = {
    name: 'phy'
  };
  response.send(JSON.stringify(data));
});