我试图从调用JS角使用Restangular一个Java REST API。 我能看到网络选项卡,但响应的对象是有空数组恰当的反应,而我试图登录控制台或显示相同的HTML文件。
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);
});
}
我在app.js文件中定义了以下配置
.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;
});
})
安慰
网络