app.use(express.json) code example

Example 1: express req get json

const express = require('express');
const app = express();

app.use(express.json());

app.post('*', (req, res) => {
  req.body;	// The json object sent to the server
});
const port = 3000;
app.listen(port, () => console.log(`Listening on port ${port}.`));

Example 2: import { Application } from "express"

import { Request, Response, Application } from 'express';
import express = require('express');

var app: Application = express();

app.get('/', function (req: Request, res: Response) {
  res.send('Hello World')
});

app.listen(3000);