0

Can any one tell me how to parse this API using Angular. I want to get all unis array elements.

$http.get('https://www.coursera.org/maestro/api/topic/list2').success(function(data)
{
    console.log("UniCtrl:" + data.unis);
    $scope.unis = data.unis;
});

But data.unis is showing as undefind.

12
  • You might have to parse data as JSON. Commented Jan 4, 2014 at 8:55
  • @Bibhas thanx, can you tell me how. Commented Jan 4, 2014 at 9:03
  • hmm, that api return content-type application/json it should automatically parse json data though. Commented Jan 4, 2014 at 9:05
  • @YOU I can't fetch the output from terminal because of SSL error. Is it possible that data is not being returned for the same reason? Commented Jan 4, 2014 at 9:07
  • 1
    If there is no public api, you need middle layer, that fetch that json from server like php or python and that pass data through to your web. Commented Jan 4, 2014 at 10:50

1 Answer 1

0
$http.jsonp('https://www.coursera.org/maestro/api/topic/list2').success(function(data) {
    JSON.parse(data); // to parse it
    console.log(data); // to see what it returns
    $scope.unis = data.unis;
});
Sign up to request clarification or add additional context in comments.

1 Comment

@decodesmith not working giving error Uncaught SyntaxError: Unexpected token :

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.