Reputation: 53
I try to make a POST request on the /login url with a JS object as payload, here is the code below. The problem is that I have two network calls, first one is an 'OPTIONS', second one is the POST.
I do not want the OPTIONS call to be made, I only want the POST call.
Thanks for your help !
var loginData = Restangular.one('login');
loginData.username = '[email protected]';
loginData.password = 'password';
return loginData.post().then(function(user) {
console.log(user.username, user.email);
});
Upvotes: 1
Views: 581
Reputation: 53
The problem was in the function addFullRequestInterceptor, I was not returning the element data.
Restangular.addFullRequestInterceptor(function(element, operation, what, url, headers, params, httpConfig) {
//some logic here...
//originally, the return below was not there... It is mandatory, if nothing is returned in that function, any POST or PUT request won't have any payload data.
return {
element: element,
headers: headers,
params: params,
httpConfig: httpConfig
};
});
Upvotes: 1