マルチファンクションを配列スタック[]にプッシュする方法。私はそれを押してループまたはwhileループを使用して、それはメッセージのエラーを表示します。おそらく非同期を使用する必要があります。助けて。 tks。これは私のスクリプトの一部です。配列は以前に格納されたマルチリンクです。マルチファンクションをjavascriptの配列に挿入する方法
var obArr = []
var stack = []
var j,
count = 0
while (count < a.length) {
stack.push(function(callback) {
request(a[count], function(error, response, body) {
let dom = body
if (!error) {
$ = cheerio.load(dom)
} else {
console.log('nothing')
}
$('.phone_number').each(function() {
sdt = $(this).text()
})
$('.member').each(function() {
email = $(this).text()
vl = validateEmail(email)
if (vl) {
email = $(this).text()
email = email.replace(/\s/g, '')
} else {
email = ' '
}
})
callback(null, sdt, email)
})
})
count++
}
// stack.push(getData)
async.parallel(stack, function(err, result) {
console.log(error)
console.log(result)
})
}
)
あなたはどんなエラーが発生しますか? –
D:\ Node \ node_modules \ request \ index.js:45 新しいエラーをスローする( '未定義は有効なURIまたはオプションオブジェクトではありません') ^ これは私のエラーです。たぶん、[count]のuriは動作しません。whileループを使わずに[0]で変更すると動作します。 エラー:undefinedは有効なuriまたはoptionsオブジェクトではありません。 D:\ Node \ node_modules \ async \にある (D:\ Node \ node_modules \ request \ index.js:45:11) (D:\ Node \ baitap \ parralle \ 2js:34:13 ) dist \ async.js:3830:at eachOfArrayLike –
最後に投稿した内容}}) – Bindrid