我正在使用Restangular并希望为我的请求设置后缀。当我在我的服务中提出请求之前在本地进行它时它正在工作,但我想在全局设置它。
当我在.config中设置它时,问题是无法正常工作。 baseUrl正在运行,但后缀仍然缺失。任何想法我做错了什么?
angular.module('app').config(function(RestangularProvider) {
RestangularProvider.setBaseUrl("/api");
// This function is used to map the JSON data to something Restangular
// expects for the paginated results
RestangularProvider.setResponseExtractor(function(response, operation, what, url) {
if (operation === "getList" && response.results) {
// Use results as the return type, and save the result metadata
// in _resultmeta
var newResponse = response.results;
newResponse._resultmeta = {
"count": response.count,
"next": response.next,
"previous": response.previous
};
return newResponse;
}
return response;
});
//RestangularProvider.setRequestSuffix('peshooo');
RestangularProvider.setRequestSuffix('.json');
});