I'm trying to use the open-graph plugin in NodeJS to get a preview image for a vine. The OG result is correct, but I can't access result[i] from within the og callback - the variable is undefined. How can I access result[i] in the OG callback?
Thing.find(function(err, result) {
for (var i = 0; i < result.length; i++) {
if (result[i].attachment) {
if (result[i].attachment.embed_type == 'vine') {
og(result[i].attachment.embed_url, function(err, meta) {
result[i].attachment.preview_image = meta.image;
result[i].save();
});
}
}
}
});