0

m gets generated in a factory with the following request:

  var m = $http({method: 'GET', url: JSONurl});

Console log of m after the GET request:

console log of m

I need to grab m's "data:" which has the Array[2] I need. How would I create a new variable with just the data array?

1
  • m.then(res => res.data) Commented Jan 23, 2017 at 2:40

1 Answer 1

3

If you look at the angularJS docs for $http, you'll see that you'll need to use the promise to get the data. So you want something along the lines of:

$http({
  method: 'GET',
  url: JSONurl
}).then(function successCallback(response) {
    //response has the data on a successful call
  }, function errorCallback(response) {
    //this response will have the error data on a failed call
  });
Sign up to request clarification or add additional context in comments.

Comments

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.