Skip to content

Instantly share code, notes, and snippets.

@floelhoeffel
Last active January 6, 2020 19:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floelhoeffel/2566d1c476e5cb96d62a8c3863851a99 to your computer and use it in GitHub Desktop.
Save floelhoeffel/2566d1c476e5cb96d62a8c3863851a99 to your computer and use it in GitHub Desktop.
import { createClient } from 'contentful'
const pollContentful = async (space, accessToken, id, publishedVersion) => {
const client = createClient({ space, accessToken })
const resp = await client.getEntries({
'sys.id': id
})
const element = resp.items[0]
const cdnVersion = element.sys.revision
if (publishedVersion > cdnVersion) {
return await pollContentful(id, publishedVersion)
} else {
return element
}
}
export default pollContentful
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment