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.
- [Vuejs]-How to retrieve value of key from an object inside an array
- [Vuejs]-How to open vuetify dialog after user logs in to application
Source:stackexchange.com