I'm using the ImgUr NPM library to upload my images. After that I would like to add the uploaded images to an album, say 'HelloWorld'.
Here is my code:
export async function uploadToImgUr(files: Buffer[]): Promise<string[]> {
const uploadPromises = files.map(async (file) => {
const formData = new FormData();
formData.append('image', file);
const response = await client.upload({
image: file,
type: 'stream',
});
// Add the uploaded image to the album, this is my guess, but not working
const resp = await client.getAlbum(brand);
resp.data.images.push(response.data);
return response.data.link;
});
return Promise.all(uploadPromises);
}
How can I do it?