Ionic-4-rest-api-calls-not-working-on-the-device

getLearningCenters(): Observable<LearningCenter> {

console.log(Api.LearningCenters);

return this.http.get<LearningCenter>(Api.LearningCenters);
}
//Api.LearningCenters="http://api.mylearnerapp.com/api/learnerningcenters"

mikrochipkid any clue?

What is the error that is showing on device?

Got this fixed by enabling server side Cors thanks for the help everyone

I’ve already enabled cors on the server side but unsuccessfully

I also got the same issue and this one is the serios which needs to be resolved.

i used the two apis.

  1. some random data api i used this one - http://dummy.restapiexample.com/api/v1/employees
  2. created in node

output for 1:
it seems to work fine in my device and in browser here is the screenshot below

output for 2: (data is not showing in the device)

bus here the second out is showing data into the browser but in the device it is not showing the data.

Not sure if this will solve your problem but it solved mine:

2 Likes

10.0.2.2 this is ur ip address right

Hi. I am facing exactly the same problem. Did u solve it?

The post you replied to is using an HTTP endpoint, not HTTPS. If that’s the case with you as well, try changing your endpoint to use HTTPS instead and see if the problem persists.

Hi. I am facing the same problem. Did u solve it?

Hi! I am already using HTTPS endpoints. It is really weird since the api calls are sent but the data is coming back with a delay. In the browser, everything works in time.

That doesn’t sound like exactly the same problem as the post you replied to. I would start a new topic, and please try to post as much information as is needed for people to reproduce your situation.

1 Like

@karabillie I am solved this problem , from this link

in AndroidManifest.xml add the android:usesCleartextTraffic=“true” as like following.

5 Likes

It worked for me thanks I could not display the data coming from my rest api in the versions of android 9 and 10 and because the more recent versions of android do not accept unsecured data that is to say unencrypted and it is therefore necessary to make these data secure by securing the address containing the rest service.

1 Like

This works for me!

thank you so much… i was going crazy @_@

1 Like

You saved my day bro god bless you

1 Like

It works for me thanks :smiling_face_with_three_hearts: