NodeJS- How to use Express.js

First as in the last tutorial, you need to create a repository and then you can advance to the express.js installing.

(npm install express -save) Is all u need to install the express in the repository, so that u can use it afterwards.

For an example, the following code can be used to use express in a simple browser test:
var express = require(‘express’);

var app = express();

app.get(‘/’,function(req,res){

res.send(“Site de Tecnologia”);

});

app.get(‘/portateis’,function(req,res){

res.send(“Categoria de Portateis”);

});

app.get(‘/smartphones’,function(req,res){

res.send(“Categoria de Smartphones”);

});

app.get(‘/tablets’,function(req,res){

res.send(“Categoria de Tablets”);

});

app.listen(8080,function(){ console.log(“Servidor ativo no porto 8080”);

});

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My best practicesy

Design an APP Routing(updating. . .)

My Adventures Running Angular Ivy inside StackBlitz: Yes, It Is Possible!

A quick introduction to Babel

Conditional Testing with Cypress

The Best NodeJS Frameworks for 2019

Data structure in Ethereum | Episode 4: Diving into examples.

If and If/Else Statements Are Harmful

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
João Saraiva

João Saraiva

More from Medium

React and Fastify — Perfect Companions

Reactify, merge React with Fastify

Google Drive API, Resumable upload — Javascript

ExpressJS routing with Decorators, Dependency Injection and reflect-metadata

Introduction to Auth0 Actions