Create your first program using ExpressJS
In this post, I have described how you can make an API using NodeJS (ExpressJS)
Posted on Thu, Oct 20 2022
Hello Friends, Welcome!
In the post I am going to make a simplest program in Node-ExpressJS.
First of all we need to install NodeJS. You can follow some steps from this post.
After installation you need to create a node app by running on your selected directory for the application...
> npm create
By entering informations you can see a package.json created on your project folder.
But we need Express JS also. So open terminal on your root folder and run command bellow :
> npm i express
Coding Time
After that now it's time to jump into coding term....
A introduction of this code below...
Code | Introduction |
const express = require("express") | To load the express module into express variable |
const app = express() | To make a express object |
let port = 8000 | To declare port where the application will run. |
app.get("/", (req, res) =>{...} ) | To set a address of routes, it can be ( app.post(), app.delete()... ) etc. |
app.listen(port, ()=>{ ... } ) | To tell the application to listen on declared port 8000. |
Full Code :
So here we go. Our first application is done. : )
Conclusion
This is just a simplest project with ExpressJS. Nowadays ExpressJS is a famous framework of NodeJS technology. You can easily build a web application using ExpressJS in few time.
Write about the post
Comments from people (0)