如何在 React Native 中设置RequestHeader?就像下面这样:
var client = new XMLHttpRequest();
client.open("GET", "http://www.example.com/api");
client.setRequestHeader("authorization", "Bearer Access_Token");
client.send();
我在 Linking api 文档中找不到任何信息。https://facebook.github.io/react-native/docs/linking.html https://facebook.github.io/react-native/docs/linking.html
要向网站发出带有标头的请求,您需要 http(s) 请求,而不是在 2 个应用程序之间链接。
正如其他答案中提到的,链接 api 没有标头。使用 http(s) 获取远程地址时确实有标头
https://facebook.github.io/react-native/docs/network.html https://facebook.github.io/react-native/docs/network.html
fetch('https://mywebsite.com/endpoint/', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body: JSON.stringify({
firstParam: 'yourValue',
secondParam: 'yourOtherValue',
})
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)