2022-04-01 09:55:23 +00:00
|
|
|
export default defineNuxtPlugin(async (/* nuxtApp */) => {
|
|
|
|
const config1 = useRuntimeConfig()
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 100))
|
2022-12-10 22:44:29 +00:00
|
|
|
const { data } = useFetch('/api/hey', { key: 'hey' })
|
2022-04-01 09:55:23 +00:00
|
|
|
const config2 = useRuntimeConfig()
|
|
|
|
return {
|
|
|
|
provide: {
|
|
|
|
asyncPlugin: () => config1 && config1 === config2
|
2022-12-10 22:44:29 +00:00
|
|
|
? 'Async plugin works! ' + config1.testConfig + (data.value?.baz ? 'useFetch works!' : 'useFetch does not work')
|
2022-04-01 09:55:23 +00:00
|
|
|
: 'Async plugin failed!'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|