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

React Native + Expo fetch cache-control

$
0
0

I am building android app using react native expo integrated with redux. The API is called using fetch method, but always the cached result is displayed. Cache-Control header doesn't go with request. I've tried two types of header definition;

 var myHeaders = new Headers();
 myHeaders.set('Accept', 'application/json');
 myHeaders.set('Content-Type', 'application/json');
 myHeaders.set('Cache-Control', 'no-cache');

 fetch(
   "http://192.168.1.71:3000/", {
      method: 'GET',
      headers: myHeaders
 })
 .then(response => console.log(response)).catch(err=>console.log(err));

and

 fetch("http://192.168.1.71:3000/",{
   "method": "POST",
   headers: {
    'cache-control': 'no-cache',
    'Accept': 'application/json',
    'Content-Type': 'application/json; charset=utf-8',
 }, cache: "no-cache",})
.then(response => console.log(response))
.catch(err=>console.log(err));

but every time request.headers in server show this:

{ accept: 'application/json',
  'content-type': 'application/json; charset=utf-8',
  host: '192.168.1.71:3000',
  connection: 'Keep-Alive',
  'accept-encoding': 'gzip',
  'user-agent': 'okhttp/3.12.1' }

No cache-control come to server-side. Am i doing something wrong?


Viewing all articles
Browse latest Browse all 28460

Trending Articles



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