axios使用
axios.get(’/user?ID=12345’)
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
// 可选地,上面的请求可以这样做
axios.get(’/user’, {
params: {ID: 1234}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
// 这个问题在CI上存在,在larveral上不存在
axios.post(’/user’, JSON.stringify({
firstName: ‘Fred’,
lastName: ‘Flintstone’
}))
.then(function (res) {
console.log(res);
})
.catch(function (err) {
console.log(err);
});