Skip to content
Related Articles

Related Articles

How to pass Node.js Output to Web Interface ?

View Discussion
Improve Article
Save Article
Like Article
  • Last Updated : 22 Sep, 2021

Most of the popular browsers today automatically handle the display of raw data output from API on the Web interface. To do this we just have to send the required data directly in API response and the browser will take care of the rest.

Modules Required:

  • express.js: To handle routing

Setting up environment and Execution:

  • Step 1: Initialize node project.
    npm init
  • Step 2: install required modules.
    npm install express

Example: Now create a file where we will write down the code to display the output on web interface.


const express = require("express");
const app = express();
app.listen(5000, () => {
  console.log(`Server is up and running on 5000 ...`);
app.get("/", (req, res) => {
    let data = {
        name: "GFG",
        age: 18,
        male: true

Output: To run node server, go to http://localhost:5000 in browser to see output.

node index.js

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!