App
client.js is for making requests to server.jsdocument.querySelector('.button').addEventListener('click', function(e) { fetch('/fetchAll', {method: 'POST'}) }); In server.js I listen to these requests and run certain functions// serve the homepage app.get('/', (req, res) => { res.sendFile(__dirname + '/index.html') }) app.post('/fetchAll', (req, res) => { browserWindow() }) Let's say helloFunc() sets a variable; const helloMessage = "Hello there"I want to be able to change the content of the index.html in accordance with helloMessage variable.How can I do that?Also, sometimes helloFunc() might be async. In this case how can I listen to it's completion to send a data to html page?Submitted December 29, 2018 at 07:00AM by eligloys
No comments:
Post a Comment