Saturday 10 June 2017

Passing function on express js Route not working

I'm just really new on Node and Express. Trying to pass a function instead of text on my route but it seems not working. I just looked up at documentation there, They mentioned only text with req.send() method. I'm trying to pass here function's but it's not working. and also the alert() not working like this req.send(alert('Hello world')) it say's alert isn't defined or something similar.

I'm trying to do here pass functions like this

function blaBla() {
    //Things to do work here...
}

app.get('/', (request, response) => {  
  response.send(blaBla());
})

**Instead of **

app.get('/', function (req, res) {
  res.send('Hello World!')
})

I hope you guy's understood my question.



via Small developer

No comments:

Post a Comment