Koa.js Hello World - Koa.js

How to develop the first app using Koa?

To develop the first app using Koa, initially a new file app.js need to b created and enter the following in it:

Save the file and type in the terminal:

The command facilitates the server to start. The app can be tested by directing to https://lcalhost:3000, in the browser and the message should appear as :

hello world

How the Koa app works?

Initally the Koa is imported in the file, and the variable koa facilitates in accessing the Koa API. Koa app is used in application creation and assigning to the variable app.

  • app.use (function) – app.use function is called upon the request to the server.
  • app.listen (port, function) – app.listen facilitates in binding and listening to the connections of specific port. app.listen facilitates in execution of the callback function.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Koa.js Topics