Nuxt - Expose all features of useAsyncData in useAsyncStoryblok #157
Replies: 5 comments 10 replies
-
|
This would be huge, especially for SSG builds with pregenerated payload.json files. |
Beta Was this translation helpful? Give feedback.
-
|
I would be happy to attempt a PR for this feature but I really need a core member to verify and create an issue for this first. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @michaelpumo @m-shum, thanks for creating these discussions around the I'm thinking of the following DX: const { data: story, status, error, refresh, clear } = await useAsyncStoryblok(
"vue/test-richtext",
{
// async options https://nuxt.com/docs/api/composables/use-async-data#params
server: true,
lazy: true,
// API options
api: {
version: "draft"
},
// Bridge options
bridge: {
}
},
);This will require a major since it's a breaking change, so I would probably add it to this milestone https://github.com/storyblok/monoblok/milestone/2 Wdyt at first glance? |
Beta Was this translation helpful? Give feedback.
-
|
@m-shum @michaelpumo https://github.com/storyblok/monoblok/releases/tag/%40storyblok%2Fnuxt%408.0.0 Got something for you both 😉 Be aware of the breaking changes, I updated the package reference here const { story, error, pending, data } = await useAsyncStoryblok('vue', {
api: {
version: 'draft',
language: 'en',
resolve_relations: 'popular-articles.articles',
},
bridge: {
resolveRelations: 'popular-articles.articles',
},
});
if (error.value) {
throw createError({
statusCode: error.value.statusCode,
statusMessage: error.value.statusMessage
});
} |
Beta Was this translation helpful? Give feedback.
-
|
Hi @alvarosabu are the types missing for useAsyncStoryblok in the package? Looks like they're empty. I'm getting everything as "any" when using this new version
Wanted to ask before submitting an issue incase I'm mistaken. The API doesn't appear to be typed. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the recommended way to integrate Storyblok + Nuxt via
useAsyncStoryblokcomposable.All is working great but once I use
resolve_relations, I am getting back everything from each relation (as is expected) which is a gigantic payload (when I only really need a few fields).Typically, if I was doing this myself with
useAsyncData, I would usetransformin the options object to trim the payload down:https://nuxt.com/docs/api/composables/use-async-data#params
Since
useAsyncStoryblokis a wrapper around Nuxt'suseAsyncData, is there perhaps a way to add the ability to pass these Nuxt-specific options to it?Currently there is no way to do this. See these lines:
monoblok/packages/nuxt/src/runtime/composables/useAsyncStoryblok.ts
Lines 33 to 38 in 1bf21ff
Only
urlis user-provided and the options object ofuseAsyncDatais not implemented.It would be great to see this added as an additional option?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions