I'm stuck in creating my first Ionic app.
Scenario:
-
Created a simple REST-API with Golang. It's working fine when i make the GET call in browser and / or Postman. The Output is:
[ { "id": 1, "name": "Leanne Graham" }, { "id": 100, "name": "I COME FROM YOUR OWN REST-API!!!" } ]
I created a simple Ionic 3 (with Angular 5) web app based on some tutorials. I just wanted to diplay my test data in an ionic-list with ngFor. This is working fine with some static (hard-coded) data.
- I then switched from hard-coded data to a REST-API. The tutorial suggested me to use
http://jsonplaceholder.typicode.com/users
. This also worked fine; I was able to display the users' data (tried only withid
andname
) in my ionic-list. - I then switched to my own REST-API. I took similar (a little less) JSON content like the one from
http://jsonplaceholder.typicode.com/users
. See above.
Problem:
My ionic-list stays empty after fetching data from my own REST-API but works with any other public API.
Thoughts:
- Since the content of my REST-API response is nearly the same as the one from
http://jsonplaceholder.typicode.com/users
i guess there is something wrong in my api-response headers. No tutorial covers the header stuff. This is why I didn't set them. I tried different headers in my response likew.Header().Set("content-type", "application/json")
but this doesn't help. - Are there general headers I always have to set when responding to a GET request from an Ionic app?
- When helpful I naturally will post my app's code here.