nodejs get请求axios
const axios = require("axios")
//axios.get("网站")
axios.get("https://www.baidu.com/")
.then(function(response){
console.log(response.data);//使用函数function获取返回服务器请求数据,获取data数据,response可以缩写res
//另外一种简化res=>{}
}).catch(error=>{
console.log(error);//捕获错误
})
//带参数请求 - 关键字params
//格式
// params:{
// word1:"",
// .....
// }
//axios.get("url",{paramms:{
// id:"",
// name:""
// }})
axios.get("https://www.baidu.com/",{
paramas:{
Item_ID:1000,
}
}).then(res=>{
console.log(res.data);
}).catch(error=>{
console.log(error);
})
//Post请求将get换成post axios.post
0 评论