0

I'm building a mobile web-app through the framework Ionic. In my app I want to get data from an API and it seems like the API does only support requests in PHP (or some server side language). Thus it does not support CORS or JSONP which I am used to making requests to through AngularJS.

How can I communicate with this API in my app? Do I have to set up some kind of API proxy or what is the most usual way to go here? Seems like a quite common problem but I got really confused when searching.. node-modules, browserify, proxies.

novalain
  • 2,181
  • 19
  • 36
  • Check the question here: http://stackoverflow.com/questions/32302518/javascript-cross-domain-json-object-reader/32369240#32369240 – Niki van Stein Sep 17 '15 at 08:44
  • No accepted answer and didn't find it very helpful. My domain does not support CORS or JSONP, so it's not possible? – novalain Sep 17 '15 at 09:08
  • Oh man.. Why on earth does one create an API without support for these features. Thank you for clearification though – novalain Sep 17 '15 at 09:24
  • Yes that is a good question, maybe because they do not want to be called by javascript :) I will add my comment as answer so you can mark it. – Niki van Stein Sep 17 '15 at 09:25

1 Answers1

0

It is possible but you need a server in the middle that uses CORS or JSONP to serve the content of the API that can be read by javascript, or you need to load the page in the ugly way using an iframe and than get the content from the iframe (if you can communicate through get requests).

Niki van Stein
  • 10,564
  • 3
  • 29
  • 62