-
-
Save floelhoeffel/2566d1c476e5cb96d62a8c3863851a99 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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