I’m implementing a POS software, that works either in browser or in desktop (using electron). I already have the SPA implemented outside the electron, so I loaded the page using some URL.
What I need now is someway to tell if the JS is running inside the electron, and call some function from the desktop node. This is because I need to print using an ESCPOS printer, and if I’m in browser I will dowload the data, but if I’m in the desktop I will search for any USB printers and print.
So I create in the electron aplication a function that recive the information by parameters and print in ESCPOS using a lib from NPM, but I need to call this function from the JS inside the SPA. There is a way to do this? Or a better way to do the same?