vuejs-starter icon indicating copy to clipboard operation
vuejs-starter copied to clipboard

Uncaught (in promise) Error: Unable to encode undefined of type undefined

Open dhavalwd opened this issue 6 years ago • 14 comments

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. screen shot 2018-08-13 at 1 31 40 pm

How to Reproduce?

Just follow all the steps mentioned in the tutorial.

dhavalwd avatar Aug 13 '18 16:08 dhavalwd

Hello @dhavalwd,

I have just followed the tutorial from the beginning, it works normally.

capture

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.

debiasio avatar Aug 16 '18 14:08 debiasio

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.

dhavalwd avatar Aug 24 '18 18:08 dhavalwd

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.

thibautdavoult avatar Feb 05 '19 00:02 thibautdavoult

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.

levimykel avatar Mar 08 '19 12:03 levimykel

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.

TheDiehard22 avatar Mar 19 '19 19:03 TheDiehard22

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.

fchengpc avatar Apr 11 '19 15:04 fchengpc

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.

zindlerb avatar Jul 18 '19 23:07 zindlerb

I am getting the same error on the getByUID and the query.

CareTiger avatar Jul 27 '19 15:07 CareTiger

@prismicio Running into this issue as well. Any word on a fix?

aaronransley avatar May 26 '21 20:05 aaronransley

I have the same Problem, some news? image

MaximilianFranke avatar Aug 23 '21 10:08 MaximilianFranke

I got the problem because my second argument in getByUID function call was undefined. using a string value fixed it!

MarineLB avatar Sep 07 '21 17:09 MarineLB

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

MaximilianFranke avatar Sep 08 '21 06:09 MaximilianFranke

I had this error, and it was because my template filed was _uid.vue (didn't work) _index.vue fixed it.

dejardine avatar Mar 25 '22 00:03 dejardine

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.

Bergrebell avatar Apr 26 '22 13:04 Bergrebell