Method call is async but return is synced
i-khan opened this issue · comments
Iftikar commented
Zohaib Aslam commented
is this fixed yet? I used the library and found the same problem.
P.E. Banfield commented
change https://github.com/helensy/base64-to-image/blob/master/index.js#L42 to use writeFileSync
then
const transformImage = async (base64Str, key) => {
let imgObj = {'fileName': key, 'type':'png'};
console.log("writing " + key);
await base64ToImage(base64Str,'./tools/images/output/',imgObj);
}
let imgKeys = Object.keys(images);
imgKeys.forEach(key => {
transformImage(images[key], key);
});
working for me. A real solution might employ a promise or callback. I will not bother to submit a PR given that the last change here was 7 years ago...