Created
June 17, 2024 23:35
-
-
Save oguzhanozcelik/e2b85ff809ce9ebfa697a1c2b2807a97 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
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