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

Why does this request only work if I have the react-native-debugger running?

$
0
0

I have a very strange problem: I am sending an axios request to my local computer in my React Native app.

This is the code for the request:

const client = axios.create({    baseURL: 'https://192.168.178.20:5000/',    headers: {'Content-Type': 'application/x-www-form-urlencoded'    }});const params = new URLSearchParams();params.append('scope', 'openid profile offline_access email');params.append('username', '<username>');params.append('password', '<password>');const response = await client.post<AuthResponse>('connect/token', params);

But the request only reaches my backend (Which is running on https://192.168.178.20:5000/) if I have activated remote debugging in the expo app and react-native-debugger opened. Otherwise I get this AxiosError:

{"message":"Network Error","name":"Error","stack":"createError@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:142265:26\nhandleError@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:142169:27\ndispatchEvent@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:32672:31\nsetReadyState@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:31756:33\n__didCompleteResponse@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:31572:29\nemit@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:3921:42\n__callFunction@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:3149:36\nhttp://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:2881:31\n__guard@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:3103:15\ncallFunctionReturnFlushedQueue@http://192.168.178.20:19001/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&minify=false&hot=false:2880:21\ncallFunctionReturnFlushedQueue@[native code]","config":{"url":"connect/token","method":"post","data":"scope=openid profile offline_access whee_api email&username=bob&password=BobDerBaumeister5%2B&client_id=whee_mobile&grant_type=password","headers":{"Accept":"application/json, text/plain, */*","Content-Type":"application/x-www-form-urlencoded"},"baseURL":"https://192.168.178.20:5000/","transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1}}

I really have no idea what the react-native-debugger has to do with this axios request.

I am using this versions:

  • React Native: 0.63.23
  • Expo: 39.0.3
  • Axios: 0.20.0
  • React Native Debugger: 0.11.5

Any more details needed?


Viewing all articles
Browse latest Browse all 6290

Trending Articles



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