Translate function breaks when used in store or asyncData
See original GitHub issueVersion
Reproduction link
https://github.com/Frankwarnaar/nuxt-i18n-translate-from-store-bug-report
Steps to reproduce
Run npm install
and then npm run dev
. Then open http://localhost:3000.
What is expected ?
In vue’s mounted
lifecycle hook on the index page, I dispatch my action alertTranslation
, in which I alert the output of i18n’s $t
function.
What is actually happening?
When running the $t function in the store, an exception is thrown: TypeError: Cannot read property 'apply' of undefined
Additional comments?
I’ve seen the same issue before, when I was trying to use the $t
function is nuxt’s asyncData
lifecycle hook.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Translate function breaks when used in store or asyncData #343
Run npm install and then npm run dev . Then open http://localhost:3000. What is expected ? In vue's mounted lifecycle hook on the...
Read more >Nuxt val.replace is not a function when get asyncData from APIs
Thats not the way to use asyncData . Your API call should be called inside the asyncData and then return your data.
Read more >NuxtJS data, asyncData, fetch and nuxtServerInit - YouTube
Get data asynchronously from NuxtJS before redndering your app or use the Fetch / nuxtServerInit methods to populate your Vuex store on the ......
Read more >Understanding Difference Between Asyncdata Fetch Nuxt
You can customize your fetch API calls using the following options: fetchOnServer (Boolean / Function | defaults to true ): When true ,...
Read more >Vue to Nuxt: Server-Side Rendering Example
Most of the users probably will use Nuxt.js and their solution - just for a better ... That means, we have to call...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually it should just work (not sure if it was fixed or I was wrong before).
Example here: https://codesandbox.io/s/nuxt-i18n-string-from-asyncdata-fx64z
i’ll just leave this here in case somebody needs to use the translate method inside
asyncData