AI智能
改变未来

关于axios的get请求和Post请求之间的区别

不配置直接用简写的那种形式

  1. 执行get请求
axios.get(\'/user?ID=12345\').then(function (response) {console.log(response);}).catch(function (error) {console.log(error);});

上面的请求也可以这样写

axios.get(\'/user\', {params: {ID: 12345}}).then(function (response) {console.log(response);}).catch(function (error) {console.log(error);})
  1. 执行post请求
axios.post(\'/user\', {firstName: \'Fred\',lastName: \'Flintstone\'}).then(function (response) {console.log(response);}).catch(function (error) {console.log(error);});

用配置的方法来写get和post请求

  1. get请求
axios({method: \'get\',url: \'/user/12345\',params: {firstName: \'Fred\',lastName: \'Flintstone\'}});

2 post请求

axios({method: \'post\',url: \'/user/12345\',data: {firstName: \'Fred\',lastName: \'Flintstone\'}});
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » 关于axios的get请求和Post请求之间的区别