I have an electron method to print:
ipcMain.on('print', (results, total) => {
PosPrinter.print(print_data, {
printerName: 'RECEIPT',
preview: false,
width: '170px', // width of content body
margin: '15 15 15 15', // margin of content body
copies: 1,
silent : true
})
.then(() => {
// some code ...
console.log("done");
return "Printing successful.."
})
.catch((error) => {
console.error(error);
return "Something went wrong."
});
I am accessing this method on the react side like:
handlePrint = (e) => {
e.preventDefault();
ipcRenderer.send('print', this.state.cheques, this.state.total);
}
How would I be able to return the status message if the printing is successful or if there is an error to the renderer?