[Vuejs]-I don't have enough knowledge as to why my DOM isn't displaying my API call results from storyblok

0👍

You do not need to use then when awaiting a promise.

const { data } = await context.app.$storyapi
  .get("cdn/stories", {
    version: "draft",
    starts_with: 'books/book-titles'
  }).then(response => {
    console.log(response);
    response.data.stories.map(mapBooks);
  });

result.posts = data.stories.map(mapBooks);

By the way, you forgot to return a value in your promises:

result.posts = await context.app.$storyapi
  .get("cdn/stories", {
    version: "draft",
    starts_with: 'books/book-titles'
  }).then(response => {
    console.log(response);
    return response.data.stories.map(mapBooks); // return the array of books
  })

Also, you should check that response.data.stories is not undefined or you might get an error.

Leave a comment