I'm having some troubles with creating a prismic-link within the Nuxt.js framework.
All seems to go smoothly, but when I click on a link to go to another page, it throws following error:
It's probably because slice.url doesn't exist somewhere where you said it should and your v-if="slice.text.length > 0 is wrong, because slice.text is an Array.
I have tried your approach and the result now is that I do indeed get a 'url is not defined' error now.
The strange thing is that I only get this after I click on a url, not on the initial page load. The url's are linking like they should then. Am I doing something wrong in the fetch that gives me this error?
I'm really confused as to why it gives me that undefined statement..
It's not strange, since you probably have an url call inside of that header component that is not there.
I'm just assuming now that this comes from your header component. If the website is static and you recently did some changes to the header component API json, you might want to try to update that header component inside prismic (just do some changes and save + republish).
If this doesn't work. Comment out everything you have in your header vue component (and it should work), and then start uncommenting one row at a time and see where it breaks.
It's hard to debug this without seeing your code or prismic setup.
Welcome to the Prismic Forum and thanks for reaching out to us.
I'd be happy to troubleshoot this. I looked into your Github project repo. Could you please provide me more information about the Github branch and the files where you have this issue?
The Github branch is the main branch since I'm soloing this project
So where is the issue exactly:
In 'layouts > default.vue' I include 'TheHeader.vue' component.
Inside that component I call 'TheHeaderNav.vue' component.
Inside 'TheHeaderNav.vue' I fetch the single nagivation prismic model called 'navigatie'.
I pass this as a 'headerNav' object inside the component 'TheHeaderNavSlices.vue'.
Inside that component I have 2 other components 'HeaderNavLinkSlice' & HeaderNavAnchorSlice'
There I insert the headerNav property inside a object to render the link.
Prismic:
Inside Prismic, the navigation model is set up with 2 tabs: nav_header & nav_footer.
Inside each tab I use slices for different types of navigation (ex: link / anchor)
The issue:
When loading the app for the first time, all renders correctly, but when I click on a link (ex: 'Over') it gives me the error message: 'Cannot read property 'url' of undefined.'
I have no idea why it does that, since all seems to work on the inital load.
I dived into your code and found that the issue is generating from index.vue file in the over-digily folder.
Can you try this with asyncData hooks instead of fetch? I've changed your code from fetch hook to asyncData and It works. Please find the screenshot: