I am using third party api.
I am new in hybrid app development and using ionic framework. It works fine with google chrome (rest-api app).But it always returns status 0 with my app.
$http.get(‘http://newapi2.opencart-api.com:80/api/rest/products/category/18’,{
headers:{
‘Origin’: ‘http://newapi2.opencart-api.com’ //‘Origin’ :‘http://localhost’
}
}).then(function(resp){
console.log('Success', resp);
// For JSON responses, resp.data contains the result
}, function(err) {
console.error(‘ERR’, err.status);
// err.status will contain the status code
})
Please help me to resolve this issue.
/*The correct response header is
{
“Date”: “Thu, 12 Nov 2015 06:46:46 GMT”,
“Content-Encoding”: “gzip”,
“X-Powered-By”: “PHP/5.4.45”,
“Connection”: “Keep-Alive”,
“Content-Length”: “2694”,
“Keep-Alive”: “timeout=5”,
“Pragma”: “no-cache”,
“Server”: “Apache/2.4.16”,
“Vary”: “Accept-Encoding,User-Agent”,
“Access-Control-Allow-Methods”: “GET, POST, PUT, DELETE”,
“Content-Type”: “application/json”,
“Access-Control-Allow-Origin”: “http://localhost”,
“Cache-Control”: “no-store, no-cache, must-revalidate, post-check=0, pre-check=0”,
“Access-Control-Allow-Credentials”: “true”,
“Access-Control-Allow-Headers”: “X-Oc-Merchant-Language, X-Oc-Store-Id, Authorization, Content-Type,X-Oc-Merchant-Id, X-Oc-Session”,
“Expires”: “Thu, 19 Nov 1981 08:52:00 GMT”
}
*/