Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 30345

Can't make a network call with cookie on React Native fetch

$
0
0

I am trying to make a network call with a Cookie in the header of the call. I am using the React-Native fetch library and I have also tried Axios and XMLHTTPRequest libraries. All of these fail to send a cookie with the header. The call is made but the Cookie is not passed.

fetch('myurl', {
  method: 'GET',
  credentials: 'include',
  headers: {
    'Accept': 'application/json',
    'Content-Type': 'application/json',
    'Cookie': `session_id="${this.state.session_id}"`
  },
})
  .then((response) => {
    console.log(response);
    return response.json();
  })
  .then((responseJson) => {
    console.log(responseJson);
    // this.setState({
    //   message2: responseJson[0].job.invoice.id
    // })
  })
  .catch((error) => {
    console.error(error);
  });

This is the portion of the code I am trying to make the call. This works 100% on iOS, does NOT work on Android.

Doing this call on Native Android works with Volley and OkHttp. Doing this call on Flutter works using the http library, both iOS and Android.

Why does React-Native not pass the cookie to my endpoint?


Viewing all articles
Browse latest Browse all 30345

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>