massive-request/main.js

25 lines
679 B
JavaScript

import axios from 'axios';
import yml from 'js-yaml';
import fs from 'fs';
import chalk from 'chalk';
async function main() {
try {
const conf = yml.load(fs.readFileSync('./config.yml', 'utf8'));
for (let value of conf.values) {
await axios({
method: conf.axios.method,
url: conf.axios.url,
headers: conf.axios.headers,
data: conf.axios.data,
});
console.log(chalk.green('[Processed]', value));
await new Promise(resolve => setTimeout(resolve, conf.interval));
}
console.log(chalk.green.bold('It has been processed successfully!'));
} catch (err) {
console.error(chalk.red('[Error]', err.message));
};
};
main();