angular-contentful icon indicating copy to clipboard operation
angular-contentful copied to clipboard

Added sync method to contentful service

Open allanweir opened this issue 8 years ago • 4 comments

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 avatar Aug 03 '16 16:08 allanweir

@allanweir — Awesome, great work!

Can you provide an example of how to consume this method?

Thanks again!

jvandemo avatar Aug 06 '16 12:08 jvandemo

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 avatar Aug 11 '16 14:08 allanweir

@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!

jvandemo avatar Aug 24 '16 09:08 jvandemo

@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 👍

jvandemo avatar Jan 30 '17 22:01 jvandemo