This is the code for my Meteor method:
fetchGumroadData: () => {
gumroadFunc(function(result){
console.log(result.length);
result.map(function(ele, index){
console.log(index);
Sales.insert({
text: 'testing',
createdAt: new Date(),
});
});
});
}
console.log(result.length)
outputs 28 in the server logs, so we know that result
is okay.
But after console.log(index)
prints out 0, the process halts. This means that the insertion into the Sales collection isn’t working out and the code halts there.
If you remove the Sales insertion command, the server logs indicate that it iterates through each element of the array just fine. console.log(index)
prints from 0 to 27 just as expected. I also tested it with console.log(ele)
and it displays all 28 sets of data just fine (they’re just javascript objects). However, when I try to insert, it seems to halt.