REST API plays a very important role in mobile applications(Android, iOS) to exchange the data between your apps and the server. You can develop Android mobile apps using Java. And you can develop an iOS mobile app using the Objective-c, Swift.

Nowadays, Many developers moving from native mobile app development to hybrid mobile app development. When they migrate from native to hybrid, they will face too many problems. One very important problem is REST API. This tutorial focuses the Ionic hybrid mobile app development.

Usually, Native mobile app developers stuck at REST API. The REST API used in the native mobile app development works fine. But when making the AJAX request using the same REST API on the Ionic, they will face error. They are.

1. REST API called successfully and got JSON data too. But the AJAX request triggering the error function instead success in the browser preview using the ionic serve.

2. Using the proxy works fine with the browser preview. However when deploying it to the emulators, especially iOS Xcode emulator it throws 404 HTTP error.
3. Cross-origin request blocked the same origin policy disallows reading the remote resource ajax

We can simply mark this problem as Ionic call API with Proxy always return 404.

Solution 1:

https://blog.ionicframework.com/handling-cors-issues-in-ionic/

Please visit the above URL, if you are getting the browser preview error in Ionic while making the REST API call and triggering the error function instead success function.

Solution 2:

REST API works fine with Ionic browser preview. However, it is not working with the iOS emulator. And you are getting the 404 error while making the HTTP request on the iOS emulator. Then you have to contact me. It is a paid solution. I will give a solution based on the problem you are facing. You can reach me at bhatathirajatut@gmail.com.

Please note that. The solution to this problem will be charged. It is not free.

Again, This problem is solved both in the Ionic 1 and Ionic2. I tested with the iOS Xcode emulator too. It works fine.