I'm trying to call my simple web api developed in Jersey, which results in:
[
{
"id": 1,
"name": "Facebook",
"userName": "abc@gmail.com",
"password": "Qwerty@123"
}
]
My jsonp get request looks like this:
this.jsonp.get('http://localhost:8080/api/rest/domains?callback=JSONP_CALLBACK')
.toPromise()
.then(response => console.log("Success: " + response),
err => console.log("Failed: " + err));
However, I'm getting following message printed in console:
Failed: Response with status: 200 Ok for URL: http://localhost:8080/DomainServiceApi/rest/domains?callback=ng_jsonp.__req0.finished
I can't figure out what is wrong with this.
EDIT: Finally my problem got solved. I returned back to using http.get method. Then on removing my now useless in memory web api imports, I got the error message that "Access-Control-Allow-Origin" should be included in my headers in the response on server side. So I included this header in my Jersey web api and everything is working fine.
If anyone is using Jersey, read How to add headers in Jersey response.