Javascript restanglar不起作用
Restangular缺少文档让我很难受。 我正在尝试使用REST端点。我使用Django Tastypie作为后端提供程序Javascript restanglar不起作用,javascript,angularjs,rest,tastypie,restangular,Javascript,Angularjs,Rest,Tastypie,Restangular,Restangular缺少文档让我很难受。 我正在尝试使用REST端点。我使用Django Tastypie作为后端提供程序 var baseQuestions = Restangular.all('questions'); baseQuestions.one($routeParams.questionId).get().then(function(question) { console.log(question); }); 在我的AngularJS应用程序配置函数中,我已确保以正确的
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端点在浏览器中工作正常
有人能告诉我我做错了什么吗?使用Restanglar调用唯一元素时,我建议这样做:
Restangular.one('questions', $routeParams.questionId).get().then(
function(question) {
console.log(question);
});
如果有帮助,请告诉我。你能
控制台.log(响应,操作)
吗?这听起来很疯狂,但它今天才开始工作。。。我不确定我改变了什么,我会查看Git提交。谢谢你的回复。