I have an ionic app (uses angular js). I am trying to make a call to my localserver (node express) using the restangular api (have also tried using $http.get).
I set the base url as
RestangularProvider.setBaseUrl('https://localhost:3000');
I have an interceptor defined to add a custom header:
interceptors.serialNumber = function (element, operation, what, url, headers, query) {
return {
headers: angular.extend({
'x-serialnumber': deviceStore.serialNumber
}, headers)
};
};
I have tried the following restangular call:
Restangular.one('Admin').get()
.then(function (data) {
console.log(data);
});
}, function (error) {
console.log(error);
});
and the following using a $http call:
$http({
method: 'GET',
url: 'https://localhost:3000/Admin',
headers: {
'Content-Type': 'application/json',
'x-serialnumber': '000000000'
}
}).then(function (data) {
console.log(data);
}, function (error) {
console.log(error);
});
I always get the error condition where data=null | status=-1 | statusText=""
I do not see ANY request on the server side. It goes to the fail case immediately.
If I remove the custom header, I see the requests on the server side and get a good response (i.e. 200).
On the server side I am using the cors module: var app = express(); app.use(cors());