javascript - Image data not loading in async waterfall -
after uploading image app, base64 image data(basically long string) not load variable during async call.
var async = require('async'); var img_data; // ... functions grab img_data frontend console.log(img_data); // works var add_item = function(){ console.log(img_data); // works async.waterfall([ function(callback){ console.log(img_data); // doesn't work settimeout(function(){ console.log(img_data); // works // stuff , save image callback(null, 'all done'); }, 1000); } ], function(err, result){ // handle err/result }); } // if add item btn clicked, add_item(); it seems img_data isn't loaded, guess, need wait. how decide time required timeout? (variation in image data size) , in cases when no image uploaded, there time wastage. how wait until image data loaded in variable?
Comments
Post a Comment