如何在Angular服务中编辑响应数据?

时间:2015-02-23 21:44:41

标签: angularjs

function _getTagObject() {
    return $http.get('http://localhost:8081/tag?limit=1').then(
        function(response) {
            response.data[0];
        });
};

我试图只返回response.data[0]

1 个答案:

答案 0 :(得分:1)

你非常接近。您只需要从response.data[0]成功回调中返回then

function _getTagObject() {
  return $http.get('http://localhost:8081/tag?limit=1').then(function(response) {
    return response.data[0];
  });
};