I am using an external API to create a set of folders in order.
chapters.forEach(function createFolder(chapter) {
axiosInstance.post(folderCreateURL, {
name: chapter,
category_id,
})
.then(response => console.log(response))
.catch(error => console.error(error));
});
Here chapters is an array which stores folder names. I need to iterate through this array, and create folders one by one. Ideally I want to call the next iteration of the loop in the then clause of the previous one - May be some kind of yield would work here, I am guessing.
So, can any one give me some pointers to help me make progress or point me to some resource that can help me solve the problem myself?