Nodejs tutorial 2 – How to pass array to nodejs app

Nodejs tutorial 2 – How to pass array to nodejs app

Source Code

// lets import express first
const express = require(“express”)
// lets create app constant and express function
const app = express()
// create an array of fruits
fruits =[“apple”, “mango”, “banana”, “orange”]
// lets create our first route
app.get(“/”,(req, res)=>{
    // lets send the array to frond end
    res.send(fruits)
})
// lets run our app on port 8080
app.listen(8080)
Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: