1

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

https://github.com/pruthviraj-vegi/Ssc-React-Native

1
  • Do you create an instance for axios that's why you use axios like this Axios.get(apiUrl);? not this axios.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. Commented Nov 14, 2023 at 3:21

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.