[Vuejs]-Fs.writeFile does not resolve

0👍

You can try this.

import { promises as fs } from 'fs';
const context = 
this.canvas.getContext("2d").drawImage(this.video, 0, 0, 1280, 720);
 const image = canvas.toDataURL("image/png");

const data = image.replace(/^data:image\/\w+;base64,/, "");
const buf = Buffer.from(data, 'base64');
 (async () => {
 try {
   await fs.writeFile(`${this.prescriptionId}.png`,buf);
 console.log('Saved')
 } catch (error) {
 console.log(error)
}
)(this);

Leave a comment