vuejs-starter
vuejs-starter copied to clipboard
Uncaught (in promise) Error: Unable to encode undefined of type undefined
Issue
I am setting up a simple page as explained in the tutorial and I am getting this error. Let me know if I am missing something here. Below is the screenshot.
How to Reproduce?
Just follow all the steps mentioned in the tutorial.
Hello @dhavalwd,
I have just followed the tutorial from the beginning, it works normally.

I don't guess what could be the problem. Can you publish your project code on a public GitHub repo, or send to me by email ([email protected]) the ZIP archive (without node_modules folder) of your project code.
I have pushed my code to Github repo. Link for the repo.
I also see that you have updated this project for Vue cli 3
. I cloned that new one and it works perfectly fine. I find this issue with older version.
I'm getting the same error message and this is the only place I've seen it associated with Prismic, so trying my luck in this issue! I'm setting up a blog with Nuxt + Prismic. On index.vue I have:
asyncData () {
const apiEndpoint = "https://thibautdavoult.prismic.io/api/v2"
return Prismic.getApi(apiEndpoint).then((api) => {
return api.getByUID('')
}).then((response) => {
return { articles: response }
})
}
When loading the page on local, this causes: "Unable to encode undefined of type undefined", and crashes my browser.
If I just change api.getByUID('')
to api.query('')
, then that works and all the documents get loaded into data:articles.
If you want to have a look at the repo: https://github.com/thibautdavoult/portfolio/tree/prismic
(branch prismic)
Like @dhavalwd, I'm thinking this may be a version issue. But still wanted to check if anyone had an idea.
Edit: So I just determined that querying by ID works. So there seems to be a problem with UID. I'd say more than likely on my end (first time with Nuxt & Prismic). I'll update if I make progress.
Hi @dhavalwd and @thibautdavoult, sorry for the delay on this. I'll add it to our backlog and someone will look into this as soon as they are able. Thanks.
I have the very same problem in a nuxt.js 2.4.0 project when using the getByUID method.
Edit: This error is only generated when missing the 'custom-type' parameter. (https://prismic.io/docs/javascript/query-the-api/sdk-quick-query-helper-functions) However, with the parameter - the method returns undefined.
having same issue, but even after i switching over to api.query('')
, im still getting
Error: Unable to encode undefined of type undefined but with TypeError: Cannot read property 'cookie' of undefined
But im using nextjs thou.
I experienced the same error recently. The reason the error was thrown for me was because the api.getByUID
api is called with:
api.getByUID('<type>', '<uid>')
not
api.getByUID('<uid>')
This is a pretty generic error message so your error may be caused by something else.
I am getting the same error on the getByUID and the query.
@prismicio Running into this issue as well. Any word on a fix?
I have the same Problem, some news?
I got the problem because my second argument in getByUID
function call was undefined
. using a string value fixed it!
I use getById
which dont accept a second String parameter and have this Problem. With a other project the same code works and i see no difference
I had this error, and it was because my template filed was _uid.vue (didn't work) _index.vue fixed it.
had the same issue. using const document = await $prismic.api.getByUID('home')
instead of const document = await $prismic.api.getByUID('home')
did the trick for me.