Skip to content

Latest commit

 

History

History
50 lines (41 loc) · 2.31 KB

301-class12.md

File metadata and controls

50 lines (41 loc) · 2.31 KB

Class 301.12

Notes

Readings

Status Codes Based On REST Methods

  • In your own words, describe what each group of status code represents:

100’s = information 200’s = success codes 300’s = redirections 400’s = client errors 500’s = server errors

  • What is a status code 202?

the request has been accepted for processing, but the processing has not been completed yet

  • What is a status code 308?

indicates that the requested resource has been permanently moved to a new URI, and future references should use that new URI with the same method

  • 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?

The ‘Forbidden’ status code is 403. It indicates that the server understood the request, but is refusing to fulfill it. This status code is typically used when the client does not have the necessary permissions to access the requested resource.

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?

it contains sensitive information (password)

  • What is middleware?

something that gets executed before it passes information to express

  • What does app.use(express.json()) do?

tells the server to expect JSON formatted data rather than POST info

  • What does the /:id mean in a route?

it means that there's a parameter that we can access with req.params.id

  • What is the difference between PUT and PATCH?

PUT updates all the information, PATCH only updates that which was changed

  • How do you make a default value in a schema?

add a default tag. E.g. if you want the current datetime on creation you could add default: Date.now() and if you didn't include a date, it'd default to the current datetime.

  • What does a 500 error status code mean?

it means that there's an error on our server

  • What is the difference between a status 200 and a status 201?

200: OK 201: Successfully created an object

Things I want to learn more about

References

  • Google Bard and ChatGPT