Looking for some guidance on pulling a list of articles from the NPR API. I have a functioning URL that returns JSON data. However, in my controller code, I seem to be having trouble accessing the object. When I use console.log to check, it just shows [object Object] and nothing more. My service setup is as follows:
app.factory('nprService', function($resource) {
//call npr api
return $resource('http://api.npr.org/queryid=61&fields=title,byline,text,image,all&output=JSON...
And here's how my controller is structured:
app.controller('ArticleListCtrl', function($scope, nprService) {
//fetch data from the service and store it in a variable
$scope.article = nprService.get();
});
I attempted using the query method to retrieve the result like this, but since it's returning a single JSON object, it didn't work as expected.
//retrieve data from the service and store it in a variable
nprService.query(function(data) {
$scope.article = data;
});
If anyone has any insights or suggestions, I would really appreciate it. Thank you in advance.