Just starting out with AngularJS and struggling to understand web services as well. My current task involves fetching a JSON object from the following URL:
To retrieve the JSON object, I need to access:
I am completely lost on how to proceed... Any assistance in modifying my code would be greatly appreciated.
Thank you in advance! Below is the JavaScript code I have:
'use strict';
var services = angular.module('services', ['ngResource']);
services.factory('dataFactory', ['$resource','$http', '$log',
function ($resource, $http, $log) {
return {
getAllUsers: function(){
return $resource('http://mylocalhostname.dev/users/list',{city_id:12}
,{
locate: {method: 'GET', isArray: true, transformResponse: $http.defaults.transformResponse.concat(function(data, headersGetter)
$log.info(data.UsersList[0]);
return data.UsersList[0].userName;
})}
}
);
}
}
}]);
Upon testing, I receive the following message in my console:
GET 200 OK 164ms angular.js (line 7772) (in red color) (an empty string)