从服务器获取数据时出现Ionic 6 / react问题

fnvucqvd  于 2022-12-08  发布在  Ionic
关注(0)|答案(1)|浏览(187)

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.
At first, I used Pixel 2 API 30, then advised to change to Pixel 4, no changes. Also tried on real android device, still behaviour is the same.
Images:
Not working in android studio

Working as intended in web app

pwuypxnk

pwuypxnk1#

更新

我解决了这个问题。这里的问题是我将package.json文件的基本URL设置为:

"proxy":"https....."

然后,在上面的文件中,在fetch中,我只添加了一个permalink。这个解决方案适用于web应用,但由于某种原因,它在android上不起作用。现在我把fetch中的代码改为whole link,它按预期工作。

相关问题