Cannot read property 'data' of undefined

I always get this error whenever i try to integrate meta document

`TypeError: /Users/desartist22/Desktop/floema/views/_includes/head.pug:21
20| meta(name="twitter:card" content="summary_large_image")

21| meta(name="twitter:title"
22| meta(name="twitter:description"
23| meta(name="twitter:image" ? : '')

Cannot read property 'data' of undefined
at eval (eval at wrap (/Users/desartist22/Desktop/floema/node_modules/pug-runtime/wrap.js:6:10), :48:90)
at template (eval at wrap (/Users/desartist22/Desktop/floema/node_modules/pug-runtime/wrap.js:6:10), :116:7)
at Object.exports.renderFile (/Users/desartist22/Desktop/floema/node_modules/pug/lib/index.js:454:38)
at Object.exports.renderFile (/Users/desartist22/Desktop/floema/node_modules/pug/lib/index.js:444:21)
at View.exports.__express [as engine] (/Users/desartist22/Desktop/floema/node_modules/pug/lib/index.js:493:11)
at View.render (/Users/desartist22/Desktop/floema/node_modules/express/lib/view.js:135:8)
at tryRender (/Users/desartist22/Desktop/floema/node_modules/express/lib/application.js:640:10)
at Function.render (/Users/desartist22/Desktop/floema/node_modules/express/lib/application.js:592:3)
at ServerResponse.render (/Users/desartist22/Desktop/floema/node_modules/express/lib/response.js:1012:7)
at /Users/desartist22/Desktop/floema/app.js:49:7`

i am too new to this prismic stuff so i not know very well about it i just following a course on awwwards and did every thing very neatly and there is no typos i checked like 10 times

github repo

Hi @ojasshukla211 ,

Welcome to the Prismic community forum, and thanks for posting this question :slight_smile: It's awesome to hear that you learned about Prismic from Awwwards!

It looks like your home template relies on data from Prismic, but in that route you're not passing any data. You could try either using a different layout for that route, adding some Prismic data for that route, or including error handling whenever you inject Prismic data.

The error handling is probably good to do in any case. On this line, for example, you could use optional chaining:

meta(name="twitter:title" content=meta?.data?.title)

Let me know if that helps, or if the error is persisting!


Hi thankyou for helping me but it still showing the same error i literally don't know why this weird error is persisting where at bizzaro's end its just works fine no problem at all

but when i remove those optional chaining

when i try to conosle.log( i do get the logs

Screenshot 2564-10-26 at 6.01.27 PM

wait wait i only added in /about route so it works there so if i add this meta to rest of the pages it will work there aswell right?

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.