Notes on CRUD
Status Codes Based on REST Methods
- In your own words, describe what each group of status code represents:
100’s = informational codes letting the client know that part of the request has been received and that the server will attempt to comply with the remaining parts.
200’s = Things are good, success codes baby!!!
300’s = redirection codes, meaning what the client wants need to be found at a different location than where they requested from (but client has to issue request to the new location).
400’s = client error, i.e. not the servers fault but the client sent the wrong kind of request.
500’s = server error codes that could mean the server is unreachable or overwhelmed, or an exception of some kind has been triggered by the request.
- What is a status code 202?
Accepted.
- What is a status code 308?
Permanent Redirect.
- What code would you use if an update didn’t return data to a client?
204 No Content
- What code would you use if a resource used to exist but no longer does?
410 Gone
- What is the ‘Forbidden’ status code?
403
Build A Rest API with Node.js, Express, & MongoDB
- Why do we need to pull our MongoDB database string out of our server and put it into our .env?
It contains the environmental variables that you don’t want publicly accessibly like your database password or even the database username.
- What is middleware?
It’s often described as the “software glue” because provides servers to apps that the operating system does not.
- What does app.use(express.json()) do?
It adds the contained middleware expression to the app which then functions to parse incoming JSON requests to put them into the request body.
- What does the /:id mean in a route?
It specifies the particular path for the route.
- What is the difference between PUT and PATCH?
PATCH supplies instructions for data modification, while PUT supplies a modified version to fully replace the current data.
- How do you make a default value in a schema?
With the syntax default:
- What does a 500 error status code mean?
A server error,
- What is the difference between a status 200 and a status 201?
Status 200 means the request was received, understood, and began being processed by the server. Status 201 indicates that a request was successful and a new resource has been created as a result.