axios打印请求的config
时间: 2023-05-16 08:07:26 浏览: 41
可以使用console.log打印axios请求的config,例如:
axios.get('/api/user', {
params: {
id: 12345
}
}).then(function (response) {
console.log(response.config);
}).catch(function (error) {
console.log(error);
});
相关问题
axios打印config
可以使用console.log来打印axios的config,示例代码如下:
axios.get('/api/data', {
params: {
id: 123
}
}).then(function (response) {
console.log(response.config);
}).catch(function (error) {
console.log(error);
});
这段代码会发送一个GET请求到/api/data,并且带上id参数,当请求成功后,会打印出config对象。
axios post请求怎么用
axios.post(url, data, config)是一个Post请求的基本形式,其中,url是请求的地址,data是请求的数据,config是请求的配置。
示例代码如下:
```
axios.post('/user', {
firstName: 'John',
lastName: 'Doe'
})
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
```
在这个例子中,我们向地址为/user的API发送了一个包含firstName和lastName的POST请求。当请求成功返回时,我们打印了响应数据。当请求失败时,我们打印了出错信息。
你还有其他问题需要我回答吗?