Skip to content

Instantly share code, notes, and snippets.

@bettysteger
Last active December 2, 2015 09:43
Show Gist options
  • Save bettysteger/3dd336f5a9a10a2dd383 to your computer and use it in GitHub Desktop.
Save bettysteger/3dd336f5a9a10a2dd383 to your computer and use it in GitHub Desktop.
Fetching feed in Angular
// BEFORE
var feedUrl = 'https://lingohub.com/blog/feed/rss2';
$http.jsonp('https://ajax.googleapis.com/ajax/services/feed/load', {params: {v: '1.0', q: feedUrl, num:-1, callback:'JSON_CALLBACK'}}).success(function(data) {
$scope.entries = data.responseData.feed.entries;
angular.forEach($scope.entries, function (entry) {
entry.publishedDate = new Date(entry.publishedDate);
});
});
// AFTER
$http.jsonp('https://lingohub.com/blog/feed/json', {cache: true, params: {callback:'JSON_CALLBACK'}}).success(function(data) {
$scope.entries = data;
angular.forEach($scope.entries, function (entry) {
entry.publishedDate = new Date(entry.date);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment