getByUID() first finds the document, then immediately crashes

Hello. I installed prismic with Express. Everything seems to be running smoothly.

There is only one problem. When I search for a document with getByUID, it first finds it and sends the information to the pug, but immediately after that it gives a document not found error.

I am sharing the code and screenshot of the errors.

app.get('/detail/:uid', async(req, res) => {
  const uid = req.params.uid
  const detail = await client.getByUID('product', uid)
  const meta = await client.getSingle('meta')
  res.render('pages/detail', {

I guess i find the problem but i do not know how to solve it.
I try to send meta data like this:

app.get('*', async(req, res, next) => {
  const meta = await client.getSingle('meta')
  res.locals.meta = meta

I guess after 'silver-necklace' comes 'main.css' as params and gives an error because it searches main.css as prismic document.

It couldn't reach main.css as I added (comment) to Pug. That's why the uid is getting the main.css value as the second. When I changed it to 'style', the problem was gone. Thanks.

Hello @ardakaanaydilek

Welcome to the Prismic community and thanks for reaching out to us.

I am glad that you found the solution. Feel free to reach out to us if you have any other questions.


1 Like