0
Restangular缺乏文檔正在使我失望。 我正在嘗試使用REST端點。我使用Django-Tastypie作爲後端提供程序。Restangular不起作用
var baseQuestions = Restangular.all('questions');
baseQuestions.one($routeParams.questionId).get().then(function(question) {
console.log(question);
});
而在我的AngularJS應用程序配置功能,我已經確定我設置Restangular正確的方式。
RestangularProvider.setBaseUrl('/api/v1');
RestangularProvider.setRequestSuffix('?format=json');
RestangularProvider.setResponseExtractor(function(response, operation, what, url) {
var newResponse;
if (operation === 'getList') {
newResponse = response.objects;
newResponse.metadata = response.meta;
} else {
newResponse = response.data;
}
return newResponse;
});
但是,打印的控制檯值顯示的問題是未定義的,顯然我不想這樣,我需要實際的數據。
REST端點在瀏覽器中正常工作。
有人可以告訴我我做錯了什麼嗎?
你可以'console.log(response,operation)'? –