反馈本机提取和基本认证
发布时间:2020-12-15 20:42:53 所属栏目:百科 来源:网络整理
导读:我尝试使用fetch与这种语法: fetch("https://user:password@url",{ ...}).then((response) = { ...}).done(); 相同的网址在CURL中工作,但在React Native中返回401. 有任何想法吗? 谢谢, 保罗 我发现这种格式https:// user:password @ url在CURL和节点中
我尝试使用fetch与这种语法:
fetch("https://user:password@url",{ ... }).then((response) => { ... }).done(); 相同的网址在CURL中工作,但在React Native中返回401. 有任何想法吗? 谢谢,
我发现这种格式https:// user:password @ url在CURL和节点中运行良好,但在fetch中不起作用.
我不得不使用base-64 npm模块并通过一个Headers对象. // https://www.npmjs.com/package/base-64 const base64 = require('base-64'); ... var headers = new Headers(); headers.append("Authorization","Basic " + base64.encode("user:password")); fetch("https://url",{ headers: headers }) .then((response) => { ... }) .done(); ` (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |