Reputation: 533
I expected my console.log statements in Javascript to appear in the terminal console of where I had started my verticle server but, it seems to be crashing..... (of course, on a client's browser it would play in the browser's console namely in Firefox - I would see it in the in built debugger - so analogously speaking it should appear on my terminals output because it is vertx's server side code execution of it's polygot rendering of javascript code)
This is the output of my running verticle in my bash terminal
Succeeded in deploying verticle
Exception in JavaScript verticle:
ReferenceError: "console" is not defined.
at file:/home/arjun/vertx_code/server.js:5 (anonymous)
at file:/opt/vert.x-2.1.3/sys-mods/io.vertx~lang-js~1.1.0/vertx/http.js:1847 (anonymous)
The javascript code that was used is the example install for a verticle from vertx.io
var vertx = require('vertx');
vertx.createHttpServer().requestHandler(function(req) {
req.response.end("Hello World!");
console.log("Reloaded");
}).listen(8080, 'localhost');
req.response.end("Hello World!");
console.log("Reloaded");
}).listen(8080, 'localhost');
Do I need another javascript package, do I need to do something along the lines of ...
var console = require('console');
Upvotes: 1
Views: 595
Reputation: 33
Yes, you should require the console before you can use it. So this should work:
var vertx = require('vertx');
var console = require('vertx/console');
vertx.createHttpServer().requestHandler(function(req) {
req.response.end("Hello World!");
console.log("Reloaded");
}).listen(8080, 'localhost');
Upvotes: 2