如何通过vuejs中的获取请求传递凭据?

问题描述

我试图通过这样的凭证:

fetch(this.url + '/auth/login',{method:'GET',headers: {'Authorization': 'Basic ' + btoa('xxxx:xxxx')}})
  .then(response => response.json())
  .then(json => console.log(json));

但是它在控制台中给出了此错误

GET https://stagingapi.pikflick.com/auth/login 404 (Not Found)

我尝试了另一种方式:

fetch(this.url + "/auth/login",{
      method: 'GET',credentials: 'include',redirect: 'follow',agent: null,headers: {
          "Content-Type": "text/plain",'Authorization': 'Basic ' + btoa('xxxx:xxxx'),}
  });

显示错误

CORS策略阻止从来源“ http:// localhost:8080”访问“ https://stagingapi.pikflick.com/auth/login”的访问权限

有人可以告诉我如何通过凭据吗?我第一次用招摇。谁能帮忙。我将非常感谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)