Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

能够请求成功:
示例一 :demo.html 然后引入axios


   axios.get("接口地址")
        .then(function (response) {
            console.log(response);
        })
        .catch(function (error) {
            console.log(error);
        });

然后直接从浏览器打开这样请求是成功的也有返回数据

不能成功请求 返回403

示例二 使用vue 请求这个接口直接返回403

示例三 或者使用node 搭建服务 把示例1的代码放到node服务中 访问node发现返回的也是403


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
3.8k views
Welcome To Ask or Share your Answers For Others

1 Answer

这并不合理,如果这个服务端是你写的,那么你贴的代码肯定有问题,很大程度上是地址没写对,请求方式不对等等

如果说这个服务端不是你的。那有可能他针对某些请求头做了处理。你对比一下请求头吧。

em....我又想到了一种可能,跨域了。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...