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

I'm trying to only return response.data[0].

1
  • 1
    Please comment on how I can make this question better. I will make the necessary edits. Commented Feb 23, 2015 at 22:00

1 Answer 1

1

You're very close. You just need to return response.data[0] from the then success callback:

function _getTagObject() {
  return $http.get('http://localhost:8081/tag?limit=1').then(function(response) {
    return response.data[0];
  });
};
Sign up to request clarification or add additional context in comments.

2 Comments

So, I think my issue here, is that my controller is expecting a promise. When I return data like this, do I resolve the promise?
@Eric can you show what you've tried in the controller?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.