CRUD
Status Codes Based On REST Methods
- In your own words, describe what each group of status code represents:
100’s = Informational
200’s = Success
300’s = Redirection
400’s = Client Error
500’s = Server Error
- What is a status code 202?
- Accepted - Often used for asynchronous processing. This code tells the client that the request was valid, but its processing will finish sometime in the future.
- What is a status code 308?
- Permanent Redirect - This tells the client to use another URL to access the resource and not use the current URL anymore.
- What code would you use if an update didn’t return data to a client?
- What code would you use if a resource used to exist but no longer does?
- What is the ‘Forbidden’ status code?
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?
- Because it is sensitive information that we don’t want to be made public.
- What is middleware?
- Code that runs after the server gets a request, but before it gets passed to your route.
- What does app.use(express.json()) do?
- Let’s the server accept JSON as a body.
- What does the /:id mean in a route?
- The
:
means id
is a parameter that we can access later.
- What is the difference between PUT and PATCH?
patch
only updates based on what the user passes, while put
updates all the information all at once, not just what was passed.
- How do you make a default value in a schema?
- Use the
default:
property in the schema object.
- What does a 500 error status code mean?
- What is the difference between a status 200 and a status 201?
- Status 200 is just a “success” message, while Status 201 is more specific meaning that something was successfully created.