i am building a react native app, through rest-api in django framework, in test mode or in expo go the code is working fine but in, but after the apk build , data is not fetching
const fetchDataFromAPI = async (code) => {
setLoading(true);
setError(null);
if (ipAddress && profileCode) {
try {
const apiUrl = `http://${ipAddress}:8000/api/stock/?i=${profileCode}&s=${code}`;
setError(apiUrl);
const response = await Axios.get(apiUrl);
const stockData = response.data;
setData(stockData);
} catch (error) {
setError('error in fetching');
setData();
} finally {
setLoading(false);
}
} else {
setError('Ip Address Not Found');
}
};
after build always getting error in fetching the total code in git repo is in following
Axios.get(apiUrl);? not thisaxios.get(apiUrl);? Or maybe it won't work when your app is running on a device that's not on the same network as your django server.