Below is the FTP folder structure:
12341
abc.json
xyz.json
12342
pqr.json
asd.json
12343
jkl.json
aaa.json
Now in node script, I'm using Basic FTP to connect the FTP.
I have array like [12341,12342,12343]
so I'm looping this array as below:
async.forEachOf(fileArray, async function(data, index, callback)
{
var list2 = await client.list(data+'/');
async.forEachOf(list2, function(data, index, callback2)
{
var data = JSON.parse(JSON.stringify(data));
latestFiles.push(data);
callback2();
},
async function (err)
{
console.log("*****************************");
console.log(latestFiles)
callback();
})
},
function (err)
{
console.log(err)
})
Above code is works fine if there is only one folder name in the array, but it is not working for multiple folders in loop.
The error is as below:
Error: User launched a task while another one is still running. Forgot to use 'await' or '.then()'?
but I'm already using await here await client.list(data+'/');