Error: Cannot read properties of undefined (reading 'openGraph')
Answered
Dunker posted this in #help-forum
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
DunkerOP
Unable to fetch parent layout's metadata, any idea what could cause this issue?
https://media.discordapp.net/attachments/663324452934778880/1163840526152372315/image.png?ex=654109f4&is=652e94f4&hm=e35d768f1433c11e8556014999fa8297f16bc977fe6ffedd4efe28ecee70b731&=&width=1140&height=513
export async function generateMetadata(props: {
params: { tournament: string; seasonNo: number }
parent: ResolvingMetadata
}): Promise<Metadata> {
const { tournament, seasonNo } = props.params
const tournamentData = await getTournamentData(tournament, seasonNo)
const { tournamentName: name, seasonNo: season } = tournamentData
const [_, imageUrl] = await getMatchesData(tournament, seasonNo)
const title = `Matches | ${name} - Season ${season}`
const description = 'Upcoming matches & results of ' + `${name}, Season ${season}`
return {
title: title,
description: description,
openGraph: {
siteName: (await props.parent).openGraph?.siteName,
title: title,
images: imageUrl,
description: description
},
twitter: {
title: title,
images: imageUrl,
description: description
}
}
}
https://media.discordapp.net/attachments/663324452934778880/1163840526152372315/image.png?ex=654109f4&is=652e94f4&hm=e35d768f1433c11e8556014999fa8297f16bc977fe6ffedd4efe28ecee70b731&=&width=1140&height=513
Answered by Chinese Egret
parent
is the second argument to generateMetadata
, not in the object 🙂8 Replies
![Avatar](https://cdn.discordapp.com/embed/avatars/4.png)
Chinese Egret
parent
is the second argument to generateMetadata
, not in the object 🙂Answer
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Take a look at the function definition here:https://nextjs.org/docs/app/api-reference/functions/generate-metadata#generatemetadata-function
And how to use parent as well ^.
Its in that code example.
![Avatar](https://cdn.discordapp.com/embed/avatars/3.png)
DunkerOP
I feel stupid, did not realize i was putting it under props object.
thanks!
thank you very much
![Avatar](https://cdn.discordapp.com/avatars/678259999201427466/1936f7e8963ff0f800f5eb4b43bc833c.webp?size=256)
Clown
Mark the answer 🙂