Readings: CRUD
Status Codes Based On REST Methods
In your own words, describe what each group of status code represents:
- 100’s = information response
- 200’s = Success code
- 300’s = redirection
- 400’s = front end error code
- 500’s = back end error code
What is a status code 202?
The request has been accepted.
What is a status code 308?
Permanent Redirect.
What code would you use if an update didn’t return data to a client?
400
What code would you use if a resource used to exist but no longer does?
301
What is the ‘Forbidden’ status code?
404
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?
so DB is not hard coded and also .env provider a secure layer.
- What is middleware?
code that runs when the server get request and before pass to routes.
- What does app.use(express.json()) do?
let our server accept json as a body instead of a post/get element
-
What does the /:id mean in a route?
it’s a param that can use later
-
What is the difference between PUT and PATCH?
PUT handles updates by replacing the entire entity, while PATCH only updates the fields that you give it.
- How do you make a default value in a schema?
by define inside the schema method
- What does a 500 error status code mean?
server side error code
- What is the difference between a status 200 and a status 201?
200: OK. The standard response for successful HTTP requests. 201: Created. The request has been fulfilled.