I'm trying to apply a Promise.all to an array of files. I want to iterate through the array and upload each file to firebase storage and then get the download link back. I get an error when I try the following
const uploadToFB = async () => {
try {
await Promise.all(
Array.from(uploadFiles!!).forEach((file) => {
return new Promise((resolve) => {
const storageRef = ref(storage, "images/" + uuid_v4() + ".jpg");
uploadBytes(storageRef, file)
.then((snapshot) => {
return getDownloadURL(snapshot.ref);
})
.then((downloadUrl) => {
resolve(downloadUrl);
});
});
})
).then((res) => {
console.log(res);
});
} catch (error) {
console.log(error);
}
};
No overload matches this call. Overload 1 of 2, '(values: [] | readonly unknown[]): Promise<[] | unknown[]>', gave the following error.
Argument of type 'void' is not assignable to parameter of type '[] | readonly unknown[]'. Overload 2 of 2, '(values: Iterable): Promise<unknown[]>', gave the following error. Argument of type 'void' is not assignable to parameter of type 'Iterable'.