angular-contentful
angular-contentful copied to clipboard
Added sync method to contentful service
Hey. Great work with this package, it's made using contentful so easy in my app! I've added a sync method for use with the /sync endpoint of contentful. It performs pretty much like the multiple entries call but also parses a sync_token from the response for use in future sync calls. Let me know your thoughts. Thanks, Allan
@allanweir — Awesome, great work!
Can you provide an example of how to consume this method?
Thanks again!
Sure. It works exactly like contentful.entries() so the code I have running is:
var query = "initial=true";
contentful
.sync(query)
.then(
// Success handler
function(response){
var entries = response.data;
var nextPageToken = response.data.nextPageToken;
var nextSyncToken = response.data.nextSyncToken;
console.log(entries + " " + nextPageToken + " " + nextSyncToken);
},
// Error handler
function(response){
console.log('Oops, error ' + response.status);
}
);
I can add this to the Readme file of the pull request if you like?
@allanweir — Fantastic, thank you! I will try out your example locally and see if everything works as expected before merging into master.
Thanks again for your great work!
@allanweir — Thank you for your great contribution. It would be awesome if you could add documentation to the README file so I can merge your PR. Thanks again 👍