Hi there,
with the JS API I want to fetch all available locales. I understood that fetching the api at cdn level returns the languages
but how would I achieve this using a JS Prismic client? Is there a prismic predicate for it?
The post I'm referring to is this one:
Hi there, is there a way to query all available locales? We are currently building a locale switch for a website will be available in 15+ different countries. I know how i can query the alternative languages as soon as i queried a specific content. But now i would need to find out which locales are generally available even if the content i currently look at hasn't been published to that locale yet.
In this case we would want to send the user to the home page of that locale as a backup solution.…
Thx
Phil
(Phil Snow)
September 3, 2020, 9:16am
2
Hi Andreas,
You just need to query the api to get that info using the method described here:
So to get the languages it would be something like:
Prismic.api("https://your-repository-name.cdn.prismic.io/api/v2").then(function(api) {
languages = api.data.languages
});
Let me know if this helps.
Fares
closed , flag & select 'Something Else' to reopen.
September 24, 2020, 12:46pm
3
This issue has been closed due to inactivity.