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

Axios request only work with react-native-debugger

$
0
0

I'm working on a tablet application where I need to fetch some data on the first page. When testing the route with Insomnia/Postman and when making that request by the app on a simulated device, with react-native-debugger on, everything works. But when I'm without the react-native-debugger or in a real device, the request doesn't work.Trying to see the request through a "proxy" I could see that the request returns an 403 error.

Where I create the HTTP Client instance:

export default axios.create({  baseURL: 'https://api.lanchecard.com.br/api',  headers: {    Accept: 'application/json',    Authorization: `Bearer ${token}`,  },});

And where I'm trying to consume data from an API:

useEffect(() => {    http      .get<IBranches[]>('/cantina')      .then((response: any) => {        console.log(response);        setBranchesList(response.data);      })      .catch((error: any) => {        console.log(error);        setBranchesList([]);      });  }, []);

Already tested to see if the token was expirated or invalid, but it isn't, always using an valid token.


Viewing all articles
Browse latest Browse all 6290

Trending Articles