storyblok-nuxt icon indicating copy to clipboard operation
storyblok-nuxt copied to clipboard

useAsyncStoryblok does not work with resolve_relations as expected

Open awacode21 opened this issue 2 years ago • 1 comments

According the docs on https://github.com/storyblok/storyblok-nuxt#2-getting-storyblok-stories-and-listen-to-visual-editor-events the composition api composable useAsyncStoryblok "is the short-hand equivalent to using useStoryblokApi inside useAsyncData and useStoryblokBridge functions separately" which i cannot confirm as i get different results.

When i use useAsyncStoryblok i get the direct story data: Bildschirmfoto 2022-12-23 um 16 23 23

whereas when using useStoryblokApi i get an object which contains a story object but also other objects like rels and so on: Bildschirmfoto 2022-12-23 um 16 25 45

So i get different data structures on both solutions. From a "short-hand equivalent" i would expect same behaviour.

Currently i need to load a story and resolve its relations. I did it as described here: https://www.storyblok.com/tp/create-and-render-blog-articles-in-storyblok-and-nuxt

but the result is only the story data, but not the rels object.

When i request it directly over browser url: https://api.storyblok.com/v2/cdn/stories/angebot/appartements?language=de&version=draft&token=246y8yrGbIXVFeVVWldUnQtt&resolve_relations=AppartementReference.appartements i get the result as expected. the overall object including story and relations.

When i request by using useStoryblokApi it is the same, i get the same results. Only when using useAsyncStoryblok i don't get the rels object, but regarding the documentation it should be there, as it is saying: "Resolved stories will be shown in a rels array at the end of the JSON response."

Expected Behavior

i would expect rels to be part of my useAsyncStoryblok response. i would expect useAsyncStoryblok and useStoryblokApi to deliver same data structure

Current Behavior

Even when following the documentation and official coding example i am not able to get the relations object over useAsyncStoryblok

Steps to Reproduce

  1. open the stackblitz https://stackblitz.com/edit/nuxt-starter-aelmwe?file=package.json,nuxt.config.ts,app.vue
  2. see reproduction in app.vue
  3. have a look what is print out in dev tools console

awacode21 avatar Dec 23 '22 15:12 awacode21