This is the code block responsible for grabbing and uploading the image
async MediaUpload(photos : any[])
{
const client = await this.Login()
const full_photo_urls : string[] = photos.map((item) => item.full)
let image_ids : string[] = [];
full_photo_urls.forEach(async (image_url) => {
const image_blob = await fetch(image_url).then(res => res.blob())
try {
console.log("images are about to be posted!");
const image_res = await client.postMediaAttachment({file: image_blob})
console.log("Images were posted here");
console.log(image_res); }
catch (error) {
console.error(error);
} }
)
return image_ids;
}
The upload process returns a status of 200, but unfortunately ends in failure triggering the catch block
Error Output:
{
"failed":true,
"json":{
"id":"111037763715692057",
"type":"image",
"url":"https://files.botsin.space/media_attachments/files/111/037/763/715/692/057/original/c46fd6ce6b892c66.jpeg",
"preview_url":"https://files.botsin.space/media_attachments/files/111/037/763/715/692/057/small/c46fd6ce6b892c66.jpeg",
"remote_url":null,
"preview_remote_url":null,
"text_url":null,
"meta":{
"original":[
"Object"
],
"small":[
"Object"
]
},
"description":null,
"blurhash":"UEHo8yIm%gV?9Exv%fM{?u~qM_D%xvITM{xa"
},
"path":"media",
"response":"Response"{
[
"Symbol(realm)"
]:null,
[
"Symbol(state)"
]:{
"aborted":false,
"rangeRequested":false,
"timingAllowPassed":true,
"requestIncludesCredentials":true,
"type":"default",
"status":200,
"timingInfo":[
"Object"
],
"cacheState":"",
"statusText":"OK"",
"headersList":[
"HeadersList"
],
"urlList":[
"Array"
],
"body":[
"Object"
]
},
[
"Symbol(headers)"
]:"HeadersList"{
"cookies":null,
[
"Symbol(headers map)"
]:[
"Map"
],
[
"Symbol(headers map sorted)"
]:null
}
},
"status":200,
"rateLimit":30
}
Despite the 200 status code being returned, the process encounters an error instead of completing successfully
I anticipate that this code should execute without errors and follow its normal sequence