Skip to content

Instantly share code, notes, and snippets.

@afrontend
Last active July 2, 2017 04:21
Show Gist options
  • Save afrontend/fafa9f7f30028a6d0e735114f6eab487 to your computer and use it in GitHub Desktop.
Save afrontend/fafa9f7f30028a6d0e735114f6eab487 to your computer and use it in GitHub Desktop.
Async 모듈 사용 후 도서 검색 코드
appendBookId(booklist, body);
var tasks = [];
_.each(booklist, function(book, key) {
var o = _.clone(opt);
o.bookId = book.bookId;
tasks.push(function (callback) {
searchDetail(o, function (err, exist) {
if (err) {
exist = false;
}
callback(null, exist);
});
})
});
async.parallel(tasks, function (err, results) {
if (err) {
getBook({msg: 'Error, Can\'t access detail information'});
return;
}
if (getBook) {
booklist = _.map(booklist, function (item, key) {
item.exist = results[key];
return item;
});
getBook(null, {
startPage: opt.startPage,
totalBookCount: totalBookCount,
booklist: booklist
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment