Providers — Basics · NestJS

Move the logic into an injectable service that keeps state across requests, and answer 404 with NotFoundException when a cat does not exist.

What you will learn

Read the theory for Providers

All Basics lessons

All NestJS courses

loading types…

What you'll learn

  • Write a provider with @Injectable() and receive it through a constructor
  • Keep state in a service and see one instance shared across requests
  • Throw NotFoundException and get Nest's 404 body without writing response code