I am trying to invoke a Java REST API from Angular JS using Restangular. I am able to see proper response in the network tab but the response object is having empty array while i try to log the same in console or display in the html file.
class TestClass {
/*@ngInject*/
constructor($log, Restangular) {
this.Restangular = Restangular;
this.$log = $log;
this.test = "somethings";
var me = this;
this.Restangular.all('api/people/').getList().then(response => {
this.test = response;
console.log(response);
});
}
I have the following configurations defined in my app.js file
.config(/*@ngInject*/function(RestangularProvider) {
RestangularProvider.setBaseUrl('http://localhost:8080/');
RestangularProvider.setFullResponse(true);
RestangularProvider.addResponseInterceptor(function(data, operation, what, url, response, deferred) {
var extractedData;
if (operation === "getList") {
extractedData = data.result;
} else {
extractedData = data;
}
return extractedData;
});
})
Console
Network