I'm trying to convert nested array of images into base64 use RNFS and it is returning me a promise and response is in Promise,Can you help me how to just get string instead of Promise.Thanks here is the ss
Here is my code
const items = order?.items?.map(i => {
return {
...i,
images: i.images.map(j => {
let response = this.getBase64(j.path);
return response;
}),
};
});
async getBase64(file) {
return await RNFS.readFile(file, 'base64');
}
Use the promise api to deal with your list of promises.
const promises = images.map(j => getBase64(j.path));
const imageResults = await Promise.all(promises); // wait for the promises to resolve.
// imageResults is now a list of whatever RNFS.readFile returns.