How to push multi function into array stack[]. I using for loop or while loop to push it but it show message error. maybe it must use async. help me. tks. This is a part of my script
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)
})
}
)
via Bi Li
No comments:
Post a Comment