GET请求
axios
.get('https://www.runoob.com/try/ajax/json_demo.json')
.then(response => (this.info = response))
.catch(function (error) {
// 请求失败处理
console.log(error);
});
POST请求
axios
.post('https://www.runoob.com/try/ajax/demo_axios_post.php')
.then(response => (this.info = response))
.catch(function (error) {
// 请求失败处理
console.log(error);
});
本文详细介绍了使用axios库进行HTTP GET和POST请求的示例,包括响应处理和错误捕获,适合初学者理解API调用的基本操作。
4159

被折叠的 条评论
为什么被折叠?



