Skip to content

Instantly share code, notes, and snippets.

@oguzhanozcelik
Created June 17, 2024 23:35
Show Gist options
  • Save oguzhanozcelik/e2b85ff809ce9ebfa697a1c2b2807a97 to your computer and use it in GitHub Desktop.
Save oguzhanozcelik/e2b85ff809ce9ebfa697a1c2b2807a97 to your computer and use it in GitHub Desktop.
export async function getServerSideProps(context) {
// @ts-ignore
let postsFinal = []
const locale = context.locale;
const seourl = context.params.seourl;
let url = `${process.env.SITE_URL_API}/detail`;
axios.get(url, {
params: {
section: "all",
locale: locale,
seourl: seourl
}
})
.then(async result => {
let data = result.data;
if (data.length > 0) {
for (const [key, value] of Object.entries(data)) {
postsFinal.push({
params: {
seourl: value.attributes.seourl
}
})
}
}
});
return {
props: {
postsFinal,
...(await serverSideTranslations(context.locale, ["common"])),
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment