Answers for "do i need express with node"

8

express js server

const express = require('express');
const app = express();
const PORT = process.env.PORT || 3000;

app.get('/', (req, res) => {
  res.send('<h1>Some HTML</h1>');
  res.send('<p>Even more HTML</p>');
});

app.listen(PORT, () => console.log(`Server is listening on port ${PORT}`));
Posted by: Guest on September-29-2020
0

how to set up an express api nodejs

const express = require('express')

const app = express() 

app.get('/', (req, res, next) => {
	res.json({
      message: 'This is my JSON api'
    });
});

app.listen(your-port-here, () => {
	console.log(`listening on http://localhost:${the-port-goes-here}`)
});

/*
WombleWoo7547 @ https://github.com/WombleWoo7547 https://replit.com/@WombleWoo7547
*/
Posted by: Guest on May-27-2021

Code answers related to "do i need express with node"

Code answers related to "Javascript"

Browse Popular Code Answers by Language