router.post('/up', verify, async (req, res) => {
if (req.files.upload.length > 0) {
var result = [];
req.files.upload.forEach((uploadFile) => {
ipfs.add(Buffer.from(uploadFile.data), function (err, upfile) {
if (err) {
console.log(err)
} else {
// THIS WORK
console.log({ "name": uploadFile.name, "cid": upfile[0].path });
// THIS NOT
result.push({ "name": uploadFile.name, "cid": upfile[0].path });
}
})
});
res.send(result);
}});
I get an empty result. How can I fix it? And what is the reason? I don't really understand it ...