TypeError: Cannot read property 'data' of undefined

 (node:24430) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'data' of undefined
[0]     at /Users/desartist22/Downloads/webpack-boilerplate-main/app.js:80:23
[0]     at processTicksAndRejections (internal/process/task_queues.js:95:5)
[0] (Use `node --trace-warnings ...` to show where the warning was created)
[0] (node:24430) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
[0] (node:24430) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

code

please do say for repo if needed



Screenshot 2564-10-27 at 5.30.46 AM

I am just gettin weird warnings like api.getByUID isn't a function idk whats going on
god I am using prismic because its used in this course this was worst experience ever with prismic

@ojasshukla211 I'm sorry that you're having a frustrating experience with Prisimc. Hopefully we can sort this out quickly.

Can you share a couple of things with me so I can help troubleshoot the problem?

  • The URL for your Prismic repository
  • The uid value of the page that you're trying to query when you get this error

If you aren't comfortable sharing this publically here, you can send it to me in a private message.

Thanks,
Levi

Thanks for the help i am really feeling so low that i cannot able to keepup with prismic. apart from that I am having a frustating experience with it dosen't mean that it isn't good it needs time to understand that i haven't invested in and went in all by taking this course from awwwards :laughing:.

btw here is the repo link: Repo LInk

UID: silver-necklace

Thanks again!

I'll look into this today and get back to you with what I find. Just so I know, are the other pages of your site working? Is it just this one that you're having trouble with?

I am having error in this page only Idk why it logs the error in the console where it just works perfectly in the browser like there is image in video of silver-necklace it complains me about it in the console but in browser it just works perfectly fine and... after sometime it complians me about .getByUID isn't a function

however i just gota fix for it prismic.client which i believe solves the issue and now i am starting to understand how prismic works :slight_smile:

This video will explain everything you need to know from what i am sufferin
and because of this error i not able to fetch the image of the silver necklace to the collections page

Alright so if I understand correctly, everything is working and displaying correctly on the site. It's just giving strange errors in the console?

The video is a little hard to see, can you send me the pug file for this page? Or even better, can you send me the entire project so I can test it here? You can either send me a zip file of the project or a link to Github (or similar).

1 Like

Thankyou for helping me

here you go with the github repo

I'm taking a look now.

1 Like

@ojasshukla211 I've taken a look and found a solution for you. I'm still not sure why this is happening, but I found that if you do a check to make sure that product exists before rendering the page, then the error messages don't appear. You could create a 404 page to display in the case that there isn't a document in Prismic to match the page. Something like this:

if (product) {
  res.render('pages/detail', {
    meta,
    product,
  });
} else {
   res.status(404).render("./error_handlers/404");
}

Give this a try and let me know if it works for you :slight_smile:

1 Like

I not get those type of error anymore but I do get this one

[0] Error: Failed to lookup view "./error_handlers/404" in views directory "/Users/desartist22/Desktop/floema/views"
[0]     at Function.render (/Users/desartist22/Desktop/floema/node_modules/express/lib/application.js:580:17)
[0]     at ServerResponse.render (/Users/desartist22/Desktop/floema/node_modules/express/lib/response.js:1012:7)
[0]     at /Users/desartist22/Desktop/floema/app.js:86:21
[0]     at processTicksAndRejections (internal/process/task_queues.js:95:5)

getting this error is like normal or still a error to solve?

thanks tho those errors aren't coming so thankyou so much i grateful for this

and yessss its solve the error i was getting in collections page thankyou i think getting this error is like normal thankyou thankyou so much man you are master :100:

Yes, that error is normal. You'll need to create a 404 page that you display if there is no product. If you want to quickly get rid of the error then replace

res.status(404).render("./error_handlers/404");

with

res.status(404).send('Page not found');

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

A post was split to a new topic: CSS not applied to specific route - express