<button onclick="switch1()">axios请求</button>
function switch1()
{
axios.get("https://www.autumnfish.cn/api/joke/list?num=6").then(function (response){console.log(response)})
}
请问这种请求axios的方式为什么不成功打印呢
<button onclick="switch1()">axios请求</button>
function switch1()
{
axios.get("https://www.autumnfish.cn/api/joke/list?num=6").then(function (response){console.log(response)})
}
请问这种请求axios的方式为什么不成功打印呢
加个catch捕获下看看?
axios.get('https://www.autumnfish.cn/api/joke/list?num=6')
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
fetch("https://www.autumnfish.cn/api/joke/list?num=6").then(res => res.json().then(console.log))
F12 控制台,没有问题,检查下你的逻辑吧
https://stackblitz.com/edit/j...
我写的这个可以打印出来