2

Let's Build Express Server. Beginners Guide

 2 years ago
source link: https://dev.to/shreyanshsheth/lets-build-express-server-beginners-guide-3od1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Cover image for Let's Build Express Server. Beginners Guide

Let's Build Express Server. Beginners Guide

What Is Express Js?

Express Js Is Web Framework For Node.js

Where To Use Express Js

  • Most Popular Use Of Express Js In the Current Time Is To Create Web Apis.
  • Also Some People Are Using To Create Full-stack Web App With using Pug, Ejs, Or Basic HTML

here we are going to create a simple API to understand concepts of express

Getting Started

Requirements

  • You need Node.js Installed In Your System. You can download node.js from Node.js

  • Open New Directory And Write This command to initialize a new project.
    npm init -y

-Now install express as dependencies for your project
npm install express

Create basic hello world API

  1. Create index.js file and import express js & initialize the app
  1. Create an endpoint

in simple term endpoint is a path where you are getting expected data
/users return all users
/products returns all products

here we have created endpoint / where we are sending hello world as a response.

3 Open a port for connections

  1. Run application > write node index.js to start the application
  1. open localhost:3000 on browser browser image

hooray you made it 🥳

what now

now try to render Html. try to create forms & process data using any database.

find material online and create your own express apps.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK