我试图使用Fetch进行GET查询,但在传递授权时得到了一个错误404。
我不知道为什么会出现这样的错误,因为当我使用像Postman这样的工具时,服务器的响应很好。
Authorization: Basic ...
method: GET
url: https://zammad.zonngo.com/api/v1/ticket_articles当我使用Javascript fetch API时,会出现错误404。
OPTIONS https://zammad.zonngo.com/api/v1/ticket_articles 404 (Not Found)这是我的密码:
const myHeaders = new Headers();
myHeaders.append('Authorization','Basic ...');
myHeaders.append('Content-Type','application/json');
fetch(URLTICKETS, {
method: 'GET',
headers: myHeaders
})
.then(response => {
console.log(response);
})
.then(error => {
console.log(error);
});如果有人能帮我就好了。
发布于 2017-11-02 01:43:40
URL上的GET方法返回401状态代码,而 OPTIONS方法实际上返回404。
http OPTIONS https://zammad.zonngo.com/api/v1/ticket_articles
HTTP/1.1 404 Not Found
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Thu, 02 Nov 2017 01:37:59 GMT
Server: nginx/1.10.3 (Ubuntu)
Transfer-Encoding: chunked
X-Request-Id: 16f58319-2658-4b0e-824c-08ca68e8d401
X-Runtime: 0.003135OPTIONS可能是由CORS飞行前请求引起的,而https://zammad.zonngo.com/似乎没有正确地处理这个请求。
https://stackoverflow.com/questions/47066142
复制相似问题