Timo
Timo
NNuxt
Created by lav on 7/15/2024 in #❓・help
UseState with a state coming from a db
at least in the docs it says
key: a unique key to ensure that data fetching can be properly de-duplicated across requests, if not provided, it will be automatically generated based on URL and fetch options
10 replies
NNuxt
Created by lav on 7/15/2024 in #❓・help
UseState with a state coming from a db
if you simply want to display the players of the db try
export const useRetrievePlayers = () => useFetch('/api/baseball/retrieve-players', {
default: () => []
});
export const useRetrievePlayers = () => useFetch('/api/baseball/retrieve-players', {
default: () => []
});
and in your component
const { data: players } = useRetrievePlayers();

// use reactive players
const { data: players } = useRetrievePlayers();

// use reactive players
this approach does not use global state but it seems like it suits your needs. useFetch deduplicates the requests automatically, so on page load all components will trigger only one request. more here
10 replies
NNuxt
Created by Timo on 5/29/2024 in #❓・help
How to enable SPA mode
Thank you! Can't wait to watch your video to get a better understanding of it 😄
6 replies