Hi everyone!
I’m having an issue with fetching the data from the server in the android applications
versions :
“@ionic/react”: “^6.0.0”,
“@ionic/react-router”: “^6.0.0”,"
“react”: “^17.0.1”,
Everything works just fine when I open the app in the browser, but when trying to preview it in Android Studio Emulator, the data seems not to be fetched, without any specific error thrown. I’m using a @redux/toolkit as a state management, tried fetching the data with axios and fetch, both approaches led to the same result.
It seems like response object is present (with status 200), but no actual data can be used.
Screenshots attached.
Thanks in advance.
I believe that is due to the emulator you are using which is running a really old WebView version which doesn’t support the latest JavaScript ECMAScript features. I know the Pixel 2 emulator doesn’t work. What emulator are you using? I know the Pixel 4 works.
Usually this isn’t an issue on real Android devices because the WebView is current (it is a separate app from the OS on Android).
Hey @twestrick, thank you for the response!
I was using Pixel 2 API 30, and I was hoping that switching to Pixel 4 would solve the issue, but however it persists. I’m currently using a Pixel 4 (as you recommended) with API 30.
Hmmm…have you looked at Dev Tools for the app running on the Android Emulator? You an get to it by going to chrome://inspect/#devices
in Chrome. That might give you some more details/context. The error kinda points to some malformed JSON, maybe in the response.
Update
I resolved the issue. The issue here is that I set a base url to package.json file as:
"proxy":"https....."
And then, in the file above, in fetch, I was adding just a permalink. This solution works for web app, but for some reason it’s not working on android. Now I changed the code inside fetch to whole link, and it works as intended.
So, API_URL from the image above was changed to the whole URL, and it works just fine.