With a single API route in Next.js, you can execute the full set of CRUD (Create, Read, Update, Delete) operations – creating a RESTful API. The req
object allows us to identify the HTTP method (PUT
, GET
, POST
, DELETE
) and keep our logic centralized in a single route.
PUT = update POST = create