Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sync method to contentful service #19

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

allanweir
Copy link

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

@jvandemo
Copy link
Owner

jvandemo commented Aug 6, 2016

@allanweir — Awesome, great work!

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

Thanks again!

@allanweir
Copy link
Author

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?

@jvandemo
Copy link
Owner

@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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants