Could someone please explain why I keep seeing the Error: Callback was already called
.
I feel I have covered all cases - so why would be 'already called':
function addVertices(outercallback) {
async.forEachLimit(fullData, 25, function (data, innercallback) {
myJson.matches.forEach(function (oMatches) {
if (data.$.id == oMatches.SourceId) {
oMatches.Ids.forEach(function (oId) {
client.execute("g.addV('test').property('id', \"" + oId + "\")", {}, (err, results) => {
if (err) {
return innercallback(console.error(err));
}
innercallback(null)
});
})
}
})
}, outercallback);
}
Infact I also tried replacing that second forEach with async.ForEach
as in the following, however is this the correct way to go?:
function addVertices(outercallback) {
async.forEachLimit(fullData, 25, function (data, innercallback) {
async.forEach(myJson, function (oMatches, innercallback2) {
if (data.$.id == oMatches.SourceId) {
oMatches.Ids.forEach(function (oId) {
client.execute("g.addV('test').property('id', \"" + oId + "\")", {}, (err, results) => {
if (err) {
return innercallback2(console.error(err));
}
innercallback2(null)
});
})
}
innercallback(null)
})
}, outercallback);
}