I am trying to fetch a image with following code:
await fetch(
`${BACKEND_URL}/api/visitors/getAvatar/${visitor.visitor.accountId}`
)
I am getting response in this format :
{"_bodyBlob": {"_data": {"__collector": [Object], "blobId": "7d70537a-3869-40d6-a9d1-bf092c2d7151", "offset": 0, "size": 10188}}, "_bodyInit": {"_data": {"__collector": [Object], "blobId": "7d70537a-3869-40d6-a9d1-bf092c2d7151", "offset": 0, "size": 10188}}, "bodyUsed": false, "headers": {"map": {"access-control-allow-credentials": "true", "access-control-allow-origin": "*", "alt-svc": "h3=":443"; ma=86400, h3-29=":443"; ma=86400, h3-28=":443"; ma=86400, h3-27=":443"; ma=86400", "cache-control": "public, max-age=86400", "cf-cache-status": "DYNAMIC", "cf-ray": "6b432d06cb116b3f-AMS", "content-length": "10188", "content-type": "image/png", "date": "Fri, 26 Nov 2021 12:38:48 GMT", "etag": "W/"27cc-PGkLO2FScsiEoWiW9u+CmIhDkaQ"", "expect-ct": "max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"", "nel": "{"success_fraction":0,"report_to":"cf-nel","max_age":604800}", "report-to": "{"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=tFCAld4YJbsHJotK05x0jrG%2FUB2tWO%2BOjAd0LTRyhuwuSJzpu5OkPtUo1CGavatZPQb62WYJL2J%2BGcD%2BI4R2GS0HItiwIBtpOPBqB70yyPCx6AU6N5BCuCtM5Ck4WgSN2cf0yWpKV6TIRxzwvqIz"}],"group":"cf-nel","max_age":604800}", "server": "cloudflare", "x-content-type-options": "nosniff", "x-download-options": "noopen", "x-frame-options": "DENY", "x-xss-protection": "1; mode=block"}}
How to extract image as base64 from this ? I have tried couple of packages like react-native-fs
and rn-fetch-blob
but they are not maintained or deprecated!