I'm trying to get the value (which is a binary data of an image) inside the body of a promise that looks like this. And is there a way to turn the binary data into a base64 encode?
"Promise"{
"IncomingMessage"{
"_readableState":"ReadableState"{...
},
"readable":false,
"_events":[...
]{...
},
"_eventsCount":4,
"_maxListeners":"undefined",
"socket":"TLSSocket"{...
},
"connection":"TLSSocket"{...
},
"httpVersionMajor":1,
"httpVersionMinor":1,
"httpVersion":"1.1",
"complete":true,
"headers":{...
},
"rawHeaders":[...
],
"trailers":{...
},
"rawTrailers":[...
],
"aborted":false,
"upgrade":false,
"url":"",
"method":null,
"statusCode":200,
"statusMessage":"OK",
"client":"TLSSocket"{...
},
"_consuming":true,
"_dumped":false,
"req":"ClientRequest"{...
},
"request":"Request"{...
},
"toJSON":[...
],
"caseless":"Caseless"{...
},
"body": //binary values here
Now, the code to access them is by console.log(getto)
inside an async function
async function getMedia(imgMsgUrl, auth) {
const getImage = {
url: imgMsgUrl,
oauth: auth,
};
var getto = get(getImage);
await getto;
console.log(getto);
};
How do I easily access the body by modifying the code inside the async function? And how do I turn it into a base64 encode?