I just realized that the asyncData hook is not called when hard refreshing the page. But I have important data to load to show on that page. And I want to make sure that they are always available, even when the user hard refreshes the page.
asyncData hook when hard refreshing in Nuxt
865 Views Asked by seref At
1
There are 1 best solutions below
Related Questions in VUE.JS
- jqBootstrapValidation() is not a function
- In Vue.js, change value of specific attribute for all items in a data array
- Vue.js - How to handle all elements with the same selector?
- How can I use Elixir + Vueify?
- Bind function on newly created element
- Vue.js Passing data to content scope
- Updating the DOM with change in an object (vue.js) - binding not working?
- websocket + vuejs: screen flickering, visible mustache code
- Vue.js nested v-repeat: How to access parent $index inside child?
- VueJS - trouble understanding .$set and .$add
- Difference between two similar functions, why is one working and the other not
- Display unescaped HTML in Vue.js
- Mouseover or hover vue.js
- vuejs: Trying to focus the input using v-el directive
- Vue.js component issue
Related Questions in NUXT.JS
- Nuxt-Express Deploying to Azure Issue
- Nuxt/ Vue - the html and js files it generates
- Nuxt/ Vue bug for calling server multiple times on a single route/ page?
- How to implement flowtype in Nuxt.js
- "document is not defined" in Nuxt.js
- Nuxt JS SSR title undefined
- Vuex - Do not mutate vuex store state outside mutation handlers
- nuxt.js How to not reload page components after $ router.push ()
- In nuxt.js (vue.js), no parameters are passed in refresh (F5)
- nuxt build --spa vs nuxt generate
- How to properly use nested components in nuxt.js
- Nuxt auth without the user endpoint
- Parameter not allowed for this message type: code_challenge_method, how to fix it in nuxt?
- maximum calstack size exceeded on vuex commit
- How to handel custom error message in nuxt js
Related Questions in ASYNCDATA
- how to send fetch request with ssr nuxt and httpOnly auth
- nuxt watchQuery not working on update route with new query
- How to pass Async data return from an Observable from Child to Parent component in Angular
- What is the Blazor 8 equivalent of asyncdata in Vuejs
- Nuxt val.replace is not a function when get asyncData from APIs
- AsyncData not being called in nuxt
- How to array destructure a Promise.all in Nuxt's asyncData
- asyncData hook when hard refreshing in Nuxt
- Nuxt: Import a js depending on i18n
- NuxtJs Typescript wait for asyncData to finish
- Nuxt/Vue CORS error on change page, with asyncData
- How to access a injected repository from a component's method
- Use fetch and asyncData together
- Call mixin function from asyncData() method of the page component with Nuxt.js
- Nuxt.js: How to debug server side after nuxt build (logging some information)
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
asyncDatafrom the documentationIn that case, the best way is to use the
fetch()hook and display a loader while you do finish your calls thanks to the$fetchState.pendinghelper.Actually, I do think that
fetch()is better in many ways.Quick article on the subject: https://nuxtjs.org/blog/understanding-how-fetch-works-in-nuxt-2-12/
The one on the bottom of the page (Sergey's) is cool with some practical example of a nice implementation too.
You could also use this somewhat hacky solution in a layout to see if the initial location (the one you are when you hard refresh) is the one you want to be. Basically, if you land on a specific page (hard refresh or following a new window page for example) but want to have some custom behavior.
Still, this one infinite loops if used in a middleware (or I made a mistake) and it's less clean than a
fetch()hook.