Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Node.Js Express, does "res.render" end the http request?

So, only do "res.render" when you are sure that everything has finished, right? Because it ends the request and shoots out a webpage.

like image 643
TIMEX Avatar asked Apr 28 '11 07:04

TIMEX


1 Answers

If you don't provide a callback to res.render(view[, options[, fn]]) it will automatically give a response with 200 HTTP Status and Content-Type: text/html

res.render('view', {}, function() {
    while (true); // should block 
});

res.render(view[, options[, fn]])

Render view with the given options and optional callback fn. When a callback function is given a response will not be made automatically, however otherwise a response of 200 and text/html is given.

express.js guide

like image 178
mak Avatar answered Oct 04 '22 09:10

mak