axios

axios

1
2
3
4
5
6
7
8
9
10
11
12
13
14
axios({
method: 'post',
url: 'xxxxxx',
data: {
a: 'data1',
b: 'data2'
}
})
.then(function(response) {
console.log(response) //请求成功
})
.catch(function(error) {
console.log(error) //请求失败
})

执行 GET 请求

1
2
3
4
5
6
7
8
9
10
11
12
13
// 为给定 ID 的 user 创建请求
axios
.get('/user', {
params: {
ID: 12345
}
})
.then(function(response) {
console.log(response)
})
.catch(function(error) {
console.log(error)
})
1
2
3
4
5
6
7
8
9
10
11
### 执行 POST 请求

axios.post('/user', {
ID: '1234'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×