I try to use getBase64 (to convert images to base64) inside a loop. The thing is that the front print the same image all the times.
const cloneResponse = JSON.parse(JSON.stringify(previewDataResponse));
async function filesToBase64() {
if (imageUpdate.length > 0) {
console.log(imageUpdate);
cloneResponse.response_json_new.finalResponse.image = await getBase64(imageUpdate[0]);
}
if(lateralImages.length > 0){
for (let i of cloneResponse.response_json_new.lateral.item_lateral){
for (let j of lateralImages){
let my64 = j;
i.image_lateral[0].path_image_lateral = await getBase64(my64);
}
}
}
}
const lateralImages is an array of objects with this structure:
[{name: 'IMG_20211015_151052.jpg', lastModified: 1663252467419, lastModifiedDate: Thu Sep 15 2022 16:34:27 GMT+0200 (hora de verano de Europa central), webkitRelativePath: '', size: 4178792}, {name: 'steps.jpg', lastModified: 1663236412688, lastModifiedDate: Thu Sep 15 2022 12:06:52 GMT+0200 (hora de verano de Europa central}]
Thanks for your help
Via Active questions tagged javascript - Stack Overflow https://ift.tt/lGtBC26
Comments
Post a Comment