Asynchronous loop, use previous answer

Hello,

I am new to Vue-js and I do not achieve my ends despite all my research …

In an asynchronous mutation loop, I try to use the result (id) of a first mutation to be able to put in “parent id” of the second mutation and so on… (This is to create a tree structure of parents / children)

Here is the code:

    foldersToCreate.map(async(folderToCreate, index) => {
              console.log(this.parentFolderId)
              await this.$apollo.mutate({
                mutation: createAssetFolderMutation,
                variables: {
                  parentFolderId: this.parentFolderId,
                  slug: folderToCreate
                },
                update: (store, info) => {
                  this.parentFolderId = info.data.assets.createFolder.id
                  console.log(this.parentFolderId)
                }
              })
            })

I think I have to use an asynchronous loop for Apollo mutations ?!

Thank you for your answers,

Kévin