Find REF with regular Javascript for use in a separate tool

Hi all,

I have a bit of a problem find the correct REF using regular Javascript for a tool I am creating. Our organisation already have a working site using Prismic and I have set up an access token for master+releases.

What I can't figure out is how to make the correct call to get the right REF for the article-ID I'm providing.

Everything should work in a browser and I don't have access to Node.JS or any similar environment from where it need to work.

Is it doable? Thanks :)

Hi @daniel.haaf,

Thanks for reaching out to us!

Refs identify which version of the repository's content should be queried. All repositories will have at least one ref pointing to the latest published content called the master ref. You can use this repository method client.getRefs();. It returns a promise that resolves with a list of all refs for the Prismic repository.

Are you caching the master ref? The master ref changes whenever you make any changes/publish content. So we don't recommend caching the master ref. Can you see the updated API response in the API browser? Here is the API browser documentation: The Rest API Browser - Documentation - Prismic.

Let me know if this answers your questions and if you have further questions.

Thanks,
Racheal.

1 Like