How to make express routing work in electron

313
September 11, 2017, at 11:39 AM

This is my code:

<script type="text/javascript">
    const express = require('express'),
    router = express.Router();
    var hosSchemaModel = require('../schema.js')
    var path    = require("path")
// const app = express()
var port = process.env.PORT || 8080;
router.listen(port);
router.get('/requests/:_id', (req, res, next) =>    {
    console.log('Dynamic Link WORKS!!');
    hosSchemaModel.findOne({ _id: req.params._id }, function(err, request){
        res.json(request)
        // res.sendFile(path.join(__dirname+'../homePage.html'))
    });
});
router.get('/all', (req, res) =>    {
    console.log('Dynamic Link WORKS!!');
    res.send('WORKS!!');
    // hosSchemaModel.findOne({ _id: req.params._id }, function(err, request){
    //  res.json(request)
    //  res.sendFile(path.join(__dirname+'../homePage.html'))
    // });
});

 module.exports = router;
</script>

I tried to put it in the main process as well but it didn't work and I figured it should be implemented in the client-side. The routers doesn't work.

when I use <a href="/all" it takes me to an empty page and nothing is printed to the console

What am I doing wrong here?

Rent Charter Buses Company
READ ALSO
Can&#39;t set headers after they are sent&hellip;no issue until I added in authentication?

Can't set headers after they are sent…no issue until I added in authentication?

I'm having some issues trying to send an axios requests with custom headers from my app so I can use them for authentication on my server

200
Every time API call firing in ReactJS

Every time API call firing in ReactJS

Using Redux created reducer, actions and service layer in our applicationI noticed when click back button it is firing the same service again

232
use for loop in node js?

use for loop in node js?

i am using for loop to retrieve the data from mongodb and display it on the browser but the problem it it iterates only for the first time and stopsSo i get only the first entry as the output

248
Node.js - Combine IBM Watson Discovery and Conversation Services

Node.js - Combine IBM Watson Discovery and Conversation Services

I know this may seem complicated but I have spent a week and a half trying to do this and can not figure it outHopefully someone can point me in the right direction

301