Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

304
Views
I'm trying to base-64 encode a PNG image file to use as a data url but the string returned is not valid

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);
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!