GET 请求传递参数
1、直接在 URL 上添加参数
import axios from 'axios'
axios.get('/api/goods/add_info/?ID=12345&firstName=Fred&lastName=Flintstone')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
2、可以通过 params 设置参数
import axios from 'axios'
axios.get('/api/goods/add_info/', {
params: {
ID: 12345,
firstName: 'Fred',
lastName: 'Flintstone',
}
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
POST 请求传递参数
1、Content-Type: application/json
import axios from 'axios'
let data = {"code":"1234","name":"yyyy"};
axios.pos