Created
July 4, 2021 05:42
-
-
Save xeusteerapat/13bd740c7433a9563942c318d7c6b6e5 to your computer and use it in GitHub Desktop.
loop create file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require('axios'); | |
const fs = require('fs/promises'); | |
const main = async () => { | |
const { data } = await axios.get('API_ENDPOINT'); | |
const tableOfContents = data.instance.details.toc.categories.map(item => { | |
return item.title; | |
}); | |
for (let [idx, content] of tableOfContents.entries()) { | |
await fs.mkdir(`${process.cwd()}/0${idx + 1}-${content}`); | |
} | |
}; | |
main().catch(err => console.log(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment