I have a base 64 string that is coming from an API call. I am testing with a sample base64 string and I am trying to convert it to pdf or an image to view in my react.js website.
I've tried many solutions, but nothing seems to work. I found a react js package that is called base64topdf
I installed it and tried to decode the base64 string to PDF, but it gives me this error "TypeError: fs.writeFileSync is not a function"
I don't know what i am doing wrong.
How can I convert a base64 string to a PDF or an image in reactjs?
Documentation to the package https://www.npmjs.com/package/base64topdf
Here is my code:
const base64 = require('base64topdf');
const base64STR = "JVBERi0xLjQKJeLjz9M...." //base64 string
const decodedBase64 = base64.base64Decode(base64STR, 'waybill');
console.log(decodedBase64)