Skip to the content.

Code 301 Class 12 Reading Notes

Status Codes Based on REST Methods

  1. In your own words, describe what each group of status code represents:
- 100's = Codes that give information telling the client that the header part of the request has been received and the server will try to comply with a transmission demand of the client.
- 200's = Success codes! Client request was accepted, but not successfully processed.
- 300's = A redirection code, the resource being requested is no longer there.
- 400's = Client error codes, invalid requests a client sent to a server. These include timeouts, wrong URI, missing authentication, etc. Client would need to confirm input parameters.
- 500's = Server error codes that indicate problems with overwhelmed servers or unreachable servers behind proxies, but also can be directly related to client requests that trigger error exceptions on the server. It's good to retry the same request, as these errors can be temporary or permanent. 
  1. What is a status code 202? Accepted - Often used for asynchronus processing. This means that the request was valid, bit its processing will finish sometime in the future.
  2. What is a status code 308? Permanent redirect -= Tells the client to use another URL to access the resource and no use the current URL anymore.
  3. What code would you use if an update didn’t return data to a client? 204 No Content
  4. What code would you use if a resource used to exist but no longer does? 406 Not Acceptable or 410 Gone
  5. What is the ‘Forbidden’ status code? 403 Forbidden

Build A REST API With Node.js, Express, & MongoDB - Quick

  1. Why do we need to pull our MongoDB database string out of our server and put it into our .env?
  2. What is middleware? Code that runs when the server gets a request, and before it gets passed to our routes.
  3. What does app.use(express.json()) do? Lets our server accept json, as a body instead of a post element, etc.
  4. What does the /:id mean in a route? The : means that it is a parameter, this can be accessed by typing in request.
  5. What is the difference between PUT and PATCH? PATCH only updates what the user passes. PUT will update all the information at once.
  6. How do you make a default value in a schema? Please see below code and notice default at the end, which is a default of time to at the moment the user request information.

json new mongoose.Schema({ name: { type: String, required: true, default: Date.now } })

  1. What does a 500 error status code mean? Internal Server Error
  2. What is the difference between a status 200 and a status 201? 200 is basic status code to tell client everything went good. 201 signals the backend-side resource creation and come along with a Location header that defines the most specific URL for that newly created resource.

Things I want to know more about

<—BACK