Express Build your first API endpoint with Express

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.
Get Unlimited PRO Access


*Enrollment provides full access to this course (and updates) for life.

Create an Express App

file_type_typescript api.ts
import express, { Request, Response } from 'express';
export const app = express();

// Allows cross origin requests
import cors from 'cors';
app.use(cors({ origin: true }));

app.use(express.json());'/test', (req: Request, res: Response) => {
  const amount = req.body.amount;
  res.status(200).send({ with_tax: amount * 7 });

Listen to Incoming Requests

file_type_typescript index.ts
// Start the API with Express
import { app } from './api';
const port = process.env.PORT || 3333;
app.listen(port, () => console.log(`API available on http://localhost:${port}`));


Ask questions via GitHub below OR chat on Slack #questions