Reputation: 525
I have to create an app with React Native that's using REST
API. The API I created is using Laravel 5.2
.
The app works as expected when I develop it in on localhost
. I'm using Laravel on localhost
with a custom port like 192.168.xx.xx:8887
, for the backend page and for the mobile app.
I have install it in my mobile, using Wifi debugger with react-native
npm start
command for opening it when there are a change.
The problem appears when I'm hosting my Laravel app on a domain. In this case I'm using 000webhost.com
. The app is so slow on fetching data and the response from fetch callback is empty, even though I input the same thing to my local backend and hosted backend. But when I'm opening the remote debugger, the application is going well again, but it's affecting my react-native
app perform, because I'm opening the remote debugger.
Are there any solution for this? Must I build my react-native
to signed-apk first before using hosted react API?
Upvotes: 2
Views: 948
Reputation: 525
After looking for a while and much of try. I got the problem is on the hosting. Whenever I call a routes that call using ajax and return a json stringify
, the page is return json stringify
format as well, but when I parse
that string
to json
, they got an error (in my case the the error is unexpected token '?'
).
I have tried to hosting in another domain and now it work like what I expected with no change on my code. I didn't know what going on, but it work on different hosting.
It also happen on my ajax datatable request
Upvotes: 1