axios強化學習

2020-05-19  本文已影响0人  dbf989ee6444

一、起步

// 写法1
axios({
  method: 'get',
  url: '',
  params: {}
}).then(res => { do something });
//  写法2
axios.get('/user', {
    params: {
      ID: 12345
    }
  })
  .then((res)=> {
    console.log(res);
  })
  .catch((error)=> {
    console.log(error);
  });
//示例:
axios.get('/user?ID=12345')
  .then((res)=> {
    console.log(res);
  })
  .catch((error)=> {
    console.log(error);
  });
//简写:
axios.get(url, params).then(res => { do something })
axios.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
  })
  .then(function (response) {
    console.log(response);
  })
  .catch(function (error) {
    console.log(error);
  });
上一篇 下一篇

猜你喜欢

热点阅读