Nuxt.js PWA and API call

Hi,

I clone the repo of this tuto : How To Create a Blazing Fast Modern Blog With Nuxt and Prismic | by Trevor-Indrek Lasn | Better Programming
In order to create a Nuxt.js PWA calling the API of my blog.

I change the API endpoint in the prismic.config file. But i have this error :

Cannot read property 'data' of undefined 14:23:12

at asyncData (pages/index.js:38:97)
at processTicksAndRejections (internal/process/task_queues.js:93:5)

I tried to find the solution, but i block... Do you have an idea?

Thanks a lot!
Kevin

Hey Kevin,

This article is really out of date,

You should check out building an app with Nuxt, Prismic and Slicemachine :slight_smile:

OR one of our sample projects than don't yet use Slicemachine:

Thanks.

Hello,

Thank you for your answer, i tried the Slice Machine tuto, but it doesn't work. The repo is not created. I have this error.

ERROR Unexpected status code [404] on URL https://warenghem2.cdn.prismic.io/api/v2?routes=[{"type"%3A"page"%2C"path"%3A"%2F%3Auid"}]

at node_modules/prismic-javascript/cjs/prismic-javascript.js:1093:25
at processTicksAndRejections (internal/process/task_queues.js:93:5)

ERROR Failed to init Prismic API, preventing app fatal error. 23:23:42

Can you tell me which version of the CLI that you're using?
You can see this by typing prismic --version in your terminal

Then can you try to npm install the latest beta version of the CLI if you don't have it yet?

npm install -g prismic-cli@3.8.3-beta.0

Once it's done you should type prismic logout then prismic login

Thanks.

Hi,

That part is working. Repo is created. But there is an issue with the _uid.vue file created, i have this error after npm run dev (i copy/past the code in https://www.slicemachine.dev/documentation/nuxt/quick-start/)

Thanks :slight_smile:

ERROR in ./pages/_uid.vue
Module Error (from ./node_modules/eslint-loader/dist/cjs.js):

/Users/kevin/nuxtjsblog/my-slicemachine-project/pages/_uid.vue
2:3 error Replace ··<slice-zone⏎········type="page"⏎········:uid="$route.params.uid"⏎··· with <slice-zone·type="page"·:uid="$route.params.uid" prettier/prettier
12:3 error Delete ·· prettier/prettier
13:1 error Replace ········SliceZone with ····SliceZone, prettier/prettier
14:1 error Delete ·· prettier/prettier
16:10 error Insert prettier/prettier

:heavy_multiplication_x: 5 problems (5 errors, 0 warnings)
5 errors and 0 warnings potentially fixable with the --fix option.

Ooo, seems like a linter issue. If you can disable your linter it will confirm this?

Thanks; But how to disable eslint from your project?

Sorry :slight_smile:
I disable it from nuxt project. But i have the Nuxt.js hello/classic page only. Not the page that says that my slice zone is empty...

Hey Kevin,

Sorry I was unavailable for a few days.

Did you add the new dynamic page as described here?

This issue has been closed due to inactivity. Flag to reopen.