axios get与post请求

九號

axios get与post请求

get请求

/api:url地址

params:{}中写参数

response:处理返回结果

1
2
3
4
5
6
7
8
axios.get('/api', {
params: {
content:''
},
}).then(
response => {
console.log(response)
})

post请求

qs.stringify()将对象 序列化成URL的形式,以&进行拼接(需要导入qs模块)

1
2
3
4
5
6
7
8
9
10
11
12
13
axios.post('/api/api/login', qs.stringify(
{
content:""
}),
{
headers: {
"CSRF-token":""
//headers发送cookies信息
}
}, )
.then(response => {
//处理返回信息
});
  • Title: axios get与post请求
  • Author: 九號
  • Created at : 2020-02-18 10:00:00
  • Updated at : 2024-03-17 22:19:21
  • Link: https://jhao.me/posts/9143/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
axios get与post请求