如何使用获取来发送授权凭据?
它使用Postman起作用,但在Chrome上,我一直收到此消息:
Request cannot be constructed from a URL that includes credentials
您无法在URL中定义user:pass@host
。只需设置授权http标头:
var headers = new Headers();
headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
fetch('https://host.com', {headers: headers})
也许您可以使用一些扩展名(例如修改标头(,并在其中包含您的凭据数据,例如联合国邮局。