Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var http = require("http"),
- fs = require('fs'),
- async = require('./js/async.js');
- var onRequest = function(request,response) {
- response.writeHead(200,{ "Content-Type": "text/html; charset=utf-8" });
- var file; // 'file' declared
- var main = function(callback) {
- fs.readFile('.\html\admin.html','utf-8',function(err,data) {
- file = data; // 'file' is given content of admin.html
- console.log('2 >> ' + typeof file);
- });
- callback(null);
- }
- console.log('1 >> ' + typeof file);
- async.series([
- main
- ], function() { // At this point 'file' is still undefined, that's odd
- response.end(); // 'cause it's a callback and should be fired after 'main'
- console.log('3 >> ' + typeof file);
- });
- }
- http.createServer(onRequest).listen(80);
- 1 >> undefined
- 3 >> undefined
- 2 >> string
- 1 >> undefined
- 2 >> string
- 3 >> string
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement