Pisandelli
Pisandelli
NNuxt
Created by Pisandelli on 9/23/2024 in #❓・help
Best way to run code once on nuxt ready
Cool @L422Y ! I was tending to create a plugin but wondering if there was a better way. Thanks for your time and help!! 🤝
3 replies
NNuxt
Created by Pisandelli on 9/23/2024 in #❓・help
Best way to run code once on nuxt ready
I need to calculate a slope for a clamp(). But I don't want to use 16 as the root font size. I need this info coming from browser. Most people use 16px as root font size, but some people use different values. To calculate the clamp accordingly I need the number... 16 or 22 or x... I can't use 1rem because is a relative unit. Anyway, the point is not the calc I need to do, but how to run a script only once, on the client side as soon as the app is ready, better before any css or html rendering. 😂
3 replies
NNuxt
Created by Sloth on 7/8/2024 in #❓・help
how do you use defineNuxtComponent asyncData()
I suggest you to give a chance to composition API... 😉
30 replies
NNuxt
Created by Sloth on 7/8/2024 in #❓・help
how do you use defineNuxtComponent asyncData()
I mean... take a look if you're missing the data: 🙂
return {
data: { // <---
hello: await $fetch('/api/hello')
}
}
return {
data: { // <---
hello: await $fetch('/api/hello')
}
}
30 replies
NNuxt
Created by Sloth on 7/8/2024 in #❓・help
how do you use defineNuxtComponent asyncData()
30 replies
NNuxt
Created by Sloth on 7/8/2024 in #❓・help
how do you use defineNuxtComponent asyncData()
did you tried:
async asyncData () {
return {
data: {
hello: await $fetch('/api/hello')
}
}
}
async asyncData () {
return {
data: {
hello: await $fetch('/api/hello')
}
}
}
30 replies