Daily Reading 12
CRUD
Status Codes Based On REST Methods
In your own words, describe what each group of status code represents:
100’s =
Informational. Here’s some information on what you’re trying to do, and what the server is doing. We will try to make this work.
200’s =
Success. Note that this is success of receiving the request, not necessarily that the request will be completed as the client has requested.
300’s =
Redirection. The request your making doesn’t go to this endpoint any more, try another request over here instead.
400’s =
Client error. Invalid request from the client to the server, such as malformation of request, or timeout. Check your request again to make sure it’s valid.
500’s =
Sever error. You sent a valid request, but the server is unable at this time to comply with it. Overloaded server, or an internal crash of the server can cause this.
What is a status code 202?
Accepted. Used for asynchronous processing. Your requested information will be delivered soon.
What is a status code 308?
Permanent redirect. Don’t use this endpoint anymore, instead use the following.
What code would you use if an update didn’t return data to a client?
501, not implemented, or 500, server error.
What code would you use if a resource used to exist but no longer does?
Typically 404, but 410 can also be used.
What is the ‘Forbidden’ status code?
Code 403.
Build A REST API With Node.js, Express, & MongoDB - Quick - First 20 minutes
Why do we need to pull our MongoDB database string out of our server and put it into our .env?
To keep it private and locally locked.
What is middleware?
Another file in your directory that your application requires in order to function correctly.
What does app.use(express.json()) do?
It lets your server accept JSON commands.
What does the /:id mean in a route?
It means that this route is a parameter that can be received by the server.
What is the difference between PUT and PATCH?
PUT will update the entire object inside the database. PATCH allows you to add or modify a single key value pair without changing the rest of it.
How do you make a default value in a schema?
the following formatting.
name: {
type: String,
required: true
}
Give the name of they key, give the datatype of the value, and if it is mandatory.
What does a 500 error status code mean?
Internal Server Error. “Something went wrong, and we don’t have a more specific error message to provide you.”
What is the difference between a status 200 and a status 201?
200 is a standard “All is good, here you go” while 201 is specifically “All is good, and what you’ve requested be created, has been.”