Hello
I’m new to Strapi and I’m trying to write an API request allowing me to obtain, depending on the specialty chosen, all the associated results (relation between my specialties table and results) which I manage to do without problem like this:
export const getStaticProps: GetStaticProps = async (context) => {
const slug = context.params?.slug;
const results = await fetcher(
`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/specialites?filters[Slug][$eq]=${slug}&populate[0]=resultats&populate[1]=Illustration&populate[2]=resultats.Image`
);
return {
props: {
results: results.data,
},
revalidate: 2 * 60,
};
};
however where I block is to recover the specialties and therefore the results in English! Basically I would like that depending on the context.locale I can retrieve the right elements in the corresponding language, any idea how to do it ?
export const getStaticProps: GetStaticProps = async (context) => {
const slug = context.params?.slug;
const { locale } = context
const language = locale === "en" ? "en-EU" : "fr-FR";
const results = await fetcher(
`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/specialites?locale=${language}?filters[Slug][$eq]=${slug}&populate[0]=resultats&populate[1]=Illustration&populate[2]=resultats.Image`
);
return {
props: {
results: results.data,
},
revalidate: 2 * 60,
};
};
I try this and so many things but the result is the same, i don’t understand how it’s works … if someone have an advice/solution don’t hesitate
Have a good day