我的 Rails API 以这种方式在响应 header 中包含分页数据:
X-Pagination {"total":332,"total_pages":12,"first_page":true,"last_page":false,"previous_page":null,"next_page":2,"out_of_bounds":false,"offset":0}
我需要在 getList() 调用期间访问此值以显示分页器等。
我已经看到标题是空的。
我该如何解决这个问题?
谢谢,斯特凡诺
最佳答案
您可以使用 setFullResponse方法它将返回所有响应数据。我想您需要一个完整的响应作为异常(exception),所以只需在本地配置 Retangular,例如:
var rest = Restangular.withConfig(function(RestangularConfigurer) {
RestangularConfigurer.setFullResponse(true);
});
rest.getList().then(function(response) {
console.log(response.headers('X-Pagination'));
});
关于pagination - 在 Restangular getList 中获取响应头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22403733/