最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React Native: set headers with the Linking api - Stack Overflow

programmeradmin3浏览0评论

How can I setRequestHeader in React Native? Like the following:

var client = new XMLHttpRequest();
client.open("GET", "");
client.setRequestHeader("authorization", "Bearer Access_Token");
client.send();

I can't find any info in the Linking api doc. .html

How can I setRequestHeader in React Native? Like the following:

var client = new XMLHttpRequest();
client.open("GET", "http://www.example./api");
client.setRequestHeader("authorization", "Bearer Access_Token");
client.send();

I can't find any info in the Linking api doc. https://facebook.github.io/react-native/docs/linking.html

Share Improve this question asked Jan 4, 2017 at 19:40 Gundam MeisterGundam Meister 1,5153 gold badges20 silver badges29 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

to make request with headers to website, you need http(s) request, not linking between 2 apps.

As mentioned in other answer, linking api does not have headers. While fetching remote address with http(s) do have headers

https://facebook.github.io/react-native/docs/network.html

fetch('https://mywebsite./endpoint/', {
  method: 'POST',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    firstParam: 'yourValue',
    secondParam: 'yourOtherValue',
  })
})

The Linking API is for linking between apps on the device. There is no notion of headers when linking between apps. Use query parameters in the URL instead.

发布评论

评论列表(0)

  1. 暂无评论