Ionic app is not getting webservice data in mobile


#1

Hi all,
I am getting issues when I run app in mobile , in iPhone when filled up login form then webservice it is doesn’t get data , getting response status fail and when run in android it is doing nothing.

I thing I am getting “request header field content-type is not allowed by access-control-allow-headers.” this error.
But in ionic server 8100 I am getting fine every thing so, please let me know what is issue.

Thanks
Shivam


#2

The backend need to send the correct headers so generally you must add this:

Access-Control-Allow-Origin: *

If your backend sends data in json format also add:

Content-Type: application/json

If your backend is written in PHP it’s as simply as add these 2 lines of code:

header(‘Access-Control-Allow-Origin: *’);
header(‘Content-Type: application/json’);


#3

Hi
Thanks to respond I added but still same issue ,nothing going with that
but I add header:{ content-type:‘undefined’} . then getting respond but nothing going to with header and in response like that failed email:"" got.
And I also added your content but nothing is going to be happened.

Thanks
Shivam


#4

Check if your app does a http get or an http post and check the backend also. If you post a little piece of code of both side could help… :smile:


#5

I tried each and every step but nothing going to happened , It is running only on ripple bete and no
where .