Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http method type changing to post after adding RestangularProvider.setDefaultHeaders(headerObject) #1299

Open
nitish24p opened this issue Jan 15, 2016 · 3 comments

Comments

@nitish24p
Copy link

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);
});

@nitish24p
Copy link
Author

works fine when $resource or $http is used

@aikrez
Copy link

aikrez commented Jan 29, 2016

Title says POST but not in your issue
which headers are you setting?

@daviesgeek
Copy link
Collaborator

@nitish24p Is this still an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants