Coffeescript 成功的重新启动请求时访问HTTP状态代码
在使用Restanglar成功请求后,如何访问HTTP响应状态代码 咖啡脚本示例Coffeescript 成功的重新启动请求时访问HTTP状态代码,coffeescript,http-status-codes,restangular,Coffeescript,Http Status Codes,Restangular,在使用Restanglar成功请求后,如何访问HTTP响应状态代码 咖啡脚本示例 我试图实现一个响应提取器,将其作为元数据附加,但当它流入提取器时,状态代码已经被剥离。您可以在模块配置中使用setFullResponse在成功请求时获取状态代码 咖啡说明: app = angular.module('app', ['restangular']) // Change setFullResponse to be true in the modules config. app.config ['R
我试图实现一个响应提取器,将其作为元数据附加,但当它流入提取器时,状态代码已经被剥离。您可以在模块配置中使用setFullResponse在成功请求时获取状态代码 咖啡说明:
app = angular.module('app', ['restangular'])
// Change setFullResponse to be true in the modules config.
app.config ['RestangularProvider', (RestangularProvider) ->
RestangularProvider.setFullResponse true
]
// Using the new response format.
app.controller 'someController', ['Restangular', (Restangular) ->
Restangular.all('orders').getList().then (result) ->
// Response from the server.
console.log result.data
// Response status code.
console.log result.status
]
希望这有帮助
var app = angular.module('app', ['restangular']);
// Change setFullResponse to be true in the modules config.
app.config(['RestangularProvider', function (RestangularProvider) {
RestangularProvider.setFullResponse(true);
}]);
// Using the new response format.
app.controller('someController', ['Restangular', function (Restangular) {
Restangular.all('orders').getList().then(function (result) {
// Response from the server.
console.log(result.data);
// Response status code.
console.log(result.status);
});
}]);
app = angular.module('app', ['restangular'])
// Change setFullResponse to be true in the modules config.
app.config ['RestangularProvider', (RestangularProvider) ->
RestangularProvider.setFullResponse true
]
// Using the new response format.
app.controller 'someController', ['Restangular', (Restangular) ->
Restangular.all('orders').getList().then (result) ->
// Response from the server.
console.log result.data
// Response status code.
console.log result.status
]