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)