var server = http.createServer(function(req, res) { res.writeHead(200); res.end('Hello Http'); }); Where do the req and res arguments come from? (abstract example)
var server = http.createServer(function(req, res) { res.writeHead(200); res.end('Hello Http'); }); Where do the req and res arguments come from? (abstract example)
If you are interested in how to create methods that work from callback , then here is an example:
var myHttp = { createServer: function(callback) { var someMyData = { hoho: true, haha: true }; callback(someMyData); } } myHttp.createServer(function(obj) { console.log(obj); }) Also work for example Promise . Frequently enough practice
Source: https://ru.stackoverflow.com/questions/601386/
All Articles