How to load more than 100 stories with the JS client in NuxtJS?

1. According to specific amount of pages

let per_page = 100
let requests = []
let totalPages = 10 // 10 pages
for(let i = 1; i <= totalPages; i++) {
  requests.push(app.$storyapi.get('cdn/stories/', {
    starts_with: 'posts/',
    per_page: per_page,
    page: i
  }))
}
let responses = await Promise.all(requests)

2. All with head request

let per_page = 100
let requests = []
let initial = await app.$storyapi.client.head('cdn/stories/', { params: { per_page: 1, page: 1, token: app.$storyapi.accessToken } })
// access total header -> Total amount of Stories
// and calculate Total amount of pages
let totalPages = Math.ceil(initial.headers.total / per_page)
for(let i = 1; i <= totalPages; i++) {
  requests.push(app.$storyapi.get('cdn/stories/', {
    starts_with: 'posts/',
    per_page: per_page,
    page: i
  }))
}
let responses = await Promise.all(requests)

Hey Hannes, I needed to fetch more than 100 Stories and found this code in one of storybloks Blogposts.

I used it in Nuxt and came across an issue with fetch and fetchstates.

Seem like when using async fetch () with two await statements, Nuxt resolves the fetch state when the first awaits promise is resolve. And this leads to all sorts of problems. For example differences between server render and client rendered nodes and so on.

Do you need more information, or have I described the problem in an understandable way?

Any idea how I can solve this?