Full Stack React: Next JS API


Uncategorized

Updated Jan 4th, 2022

Love this feature of Next JS. Eliminated the need for a second project hosted on Heroku or another node host.

Has page-based-routing so no need for a router file.

Open up network tab in the dev tools and reload

Click on the route in the name column

Can see reponse and headers

The data in these routes are not exposed to the front-end…What about utility functions in the lib folder?

Store in database, file, or array (for developement)

Can import fs and path since this is node code & runs on the server

use this to write to a file (actually read, and overwrite)

API Basics

API all about handling HTTP requests to send and receive data in JSON format to the server and/or the database. These are behind the scenes requests.

See things like:
res.status(200).json({}), also req.method() and req.body()


Top