Skip to content

Instantly share code, notes, and snippets.

Created June 15, 2015 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/73794d18a5784799deb0 to your computer and use it in GitHub Desktop.
Save anonymous/73794d18a5784799deb0 to your computer and use it in GitHub Desktop.
.factory('feed', function($http, vk, $localStorage){
var owner_id = '-34882023';
var version = '5.34';
var count = '5';
var items = [];
var liked;
var isLiked = function(itemId){
return vk.call('likes.isLiked', {item_id: itemId, owner_id: owner_id, access_token: $localStorage.token, type: 'post', v: version}).then(function(result){
return result;
}, function(err){console.log('err' + err)});
};
return {
getFeed: function(offset){
return vk.call('wall.get', {owner_id: owner_id, offset: offset, count: count, v: version}).then(function(res){
console.log(res);
items = res.data.response.items;
for(var i = 0; i < items.length; i++){
isLiked(items[i].id).then(function(ress){
if(ress.data.response.liked == true){
console.log(items[i]);
}
});
}
return items;
}, function(err){
console.log('cant call');
});
},
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment