Friday, 17 March 2017

Node React no view template - get route not called

I'm new to node. I was using express-handlebars as my view-engine, but now I've added React and I understood that I no longer require handlebars. The problem that I'm having is that in order to get to the index.html page, without handlebars, I had to use

app.use(express.static('./public'));

Everything gets rendered from react, but what if I want to do some other things when the user goes to the index page like

app.get("/",function(req,res){
    console.log("connected");
});

If I add the get request after exporting the static files, the console.log never gets called. If I use it before, it does get called, but I can see the page loading forever. How should I structure the application now that I'm using react and I don t have a view engine anymore?



via Bogdan Daniel

No comments:

Post a Comment