I'm sending a request to an api to get back a png file. if I console.log that file, it starts with this: �PNG → IHDR☻X☻♠� etc.etc.
When I try to encode it in base64, to use it later in an img element, the encoded string starts with /VBOR instead of iVBOR and it's just different than what the correct format should be.
This is my code:
var axios = require("axios").default;
var btoa = require("btoa")
var options = {
method: 'POST',
url: 'https://qrcode3.p.rapidapi.com/qrcode/text',
headers: {
'content-type': 'application/json',
'x-rapidapi-host': 'qrcode3.p.rapidapi.com',
'x-rapidapi-key': '*****'
},
data: {
data: 'https://linqr.app',
image: {uri: 'icon://appstore', modules: true},
style: {
module: {color: 'black', shape: 'default'},
inner_eye: {shape: 'default'},
outer_eye: {shape: 'default'},
background: {}
},
size: {width: 600, quiet_zone: 4, error_correction: 'M'},
output: {filename: 'qrcode', format: 'png'}
}
};
axios.request(options).then(function (response) {
console.log(btoa(response.data));
}).catch(function (error) {
console.error(error);
});