You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So i am making client side calls to an api which has CORS enabled . When setDefaultHeaders is not set the http call which is a GET method gives the correct response , on setting the headers the call type changes to OPTION and i get a 405. Angular version is 1.5.1 , apis are on nginx 1.8.0
Code:
var app = angular.module('doctorApp', ['ui.router', 'restangular']);
app.config(function($interpolateProvider, $stateProvider, $urlRouterProvider, RestangularProvider) {
RestangularProvider.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
var extractedData;
// .. to look for getList operations
if (operation === "getList") {
// .. and handle the data and meta data
extractedData = data.articles;
}
return extractedData;
});
var baseUrl = DomainRedirectService.getHost('subdomainName');
RestangularProvider.setBaseUrl(baseUrl);
RestangularProvider.setDefaultHeaders(headerObj);
}
Get Method in a controller
var params = {category:'Sports' }
Restangular.all('api/articles')
.get(params)
.then(function(articles){
console.log(articles);
});
The text was updated successfully, but these errors were encountered:
So i am making client side calls to an api which has CORS enabled . When setDefaultHeaders is not set the http call which is a GET method gives the correct response , on setting the headers the call type changes to OPTION and i get a 405. Angular version is 1.5.1 , apis are on nginx 1.8.0
Code:
var app = angular.module('doctorApp', ['ui.router', 'restangular']);
app.config(function($interpolateProvider, $stateProvider, $urlRouterProvider, RestangularProvider) {
RestangularProvider.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
var extractedData;
// .. to look for getList operations
if (operation === "getList") {
// .. and handle the data and meta data
extractedData = data.articles;
}
return extractedData;
});
}
Get Method in a controller
var params = {category:'Sports' }
Restangular.all('api/articles')
.get(params)
.then(function(articles){
console.log(articles);
});
The text was updated successfully, but these errors were encountered: