「Node.js」async.eachのエラーハンドリング処理を実装するサンプル

2020年11月23日

構文
async.each(配列名, callback)
準備
1.asyncを導入
npm install async
2.モジュールを読み込む
const async = require('async’);

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
var cftArr = ['A001', 'B002', 'C003, 'DD04', 'EE05'];
async.each(cftArr, function(ele, callback) {
console.log(ele);
callback();
},function(msg){
if(msg) console.log('error happened');
concole.log('ok')
});
var cftArr = ['A001', 'B002', 'C003, 'DD04', 'EE05']; async.each(cftArr, function(ele, callback) { console.log(ele); callback(); },function(msg){ if(msg) console.log('error happened'); concole.log('ok') });
var cftArr = ['A001', 'B002', 'C003, 'DD04', 'EE05'];
async.each(cftArr, function(ele, callback) {

  console.log(ele);
  callback();
},function(msg){

  if(msg) console.log('error happened');
  concole.log('ok')

});

 

Node.js

Posted by arkgame