Unhandled Promise Rejection Warning: TypeError: api.getByUID is not a function

[0]     at /Users/desartist22/Desktop/floema/app.js:80:29
[0]     at Layer.handle [as handle_request] (/Users/desartist22/Desktop/floema/node_modules/express/lib/router/layer.js:95:5)
[0]     at next (/Users/desartist22/Desktop/floema/node_modules/express/lib/router/route.js:137:13)
[0]     at Route.dispatch (/Users/desartist22/Desktop/floema/node_modules/express/lib/router/route.js:112:3)
[0]     at Layer.handle [as handle_request] (/Users/desartist22/Desktop/floema/node_modules/express/lib/router/layer.js:95:5)
[0]     at /Users/desartist22/Desktop/floema/node_modules/express/lib/router/index.js:281:22
[0]     at param (/Users/desartist22/Desktop/floema/node_modules/express/lib/router/index.js:354:14)
[0]     at param (/Users/desartist22/Desktop/floema/node_modules/express/lib/router/index.js:365:14)
[0]     at Function.process_params (/Users/desartist22/Desktop/floema/node_modules/express/lib/router/index.js:410:3)
[0]     at next (/Users/desartist22/Desktop/floema/node_modules/express/lib/router/index.js:275:10)
[0] (Use `node --trace-warnings ...` to show where the warning was created)
[0] (node:1697) 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:1697) [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.

Hi @ojasshukla211,

Thanks for sharing this error. Could you show your entire app.js file? (It looks like that's where the error is occurring.) Also, if you configure you api object in a different file, could you share that file as well?

Thanks,
Sam

here you go with the file app.js thanks for helping me

Hi @ojasshukla211,

I'm not sure if this will make a difference, but we now recommend Prismic.client() instead of Prismic.getApi() to init a Prismic API client. Could you try changing that and see if it helps?

Sam

1 Like

this solves the issue .getByUID is not a function but when i console.log this (product.data.image.url) it gives me cannot read property data of undefined. however i posted a another issue for it thanks for helpin me tho really appreciate the efforts you put in

1 Like

Threads close after a period of inactivity. Flag this thread to re-open it and continue the conversation.