我正在为我的一个班级写的这段代码不会打印它所写的内容。我问了周围,没有人能弄清楚。可能与向量或任何字符串有关吗? 我将打印出输入的命令行参数的地方最远。 在cygwin上编译时,它不会遇到任何可以打印出的错误。
/* eslint-disable no-plusplus */
const faker = require('faker');
const axios = require('axios');
const path = require('path');
const fs = require('fs');
const url = [];
// 100 fake avatar url from fakter
for (let i = 0; i < 100; i++) {
url.push(faker.image.avatar());
}
// download 100 user photoes to local image folder
for (let i = 0; i < url.length; i++) {
// path for image storage
const imagePath = path.join(__dirname, '../image', `${i}.jpg`);
axios({
method: 'get',
url: url[i],
responseType: 'stream',
})
.then((response) => {
response.data.pipe(fs.createWriteStream(imagePath));
});
}