reading-notes
reading notes for code fellows
Project maintained by dLeigh01
Hosted on GitHub Pages — Theme by mattgraham
CRUD
It is important to learn the different status codes so you know what to send/ what ones you are being sent mean and also its good to go again over linking up with a database to be sure you’ve got it clear.
Status Codes Based on REST Methods
An HTTP status code is a number between 100 and 600 that is part of an HTTP response. The first digit denotes the class of the response and it comes with a reason phrase.
Status classes:
- 100-199: Informational - part of the request has been recieved and the server will attempt to comply.
- 200-299: Success - the request was accepted.
- 300-399: Redirection - the resource requested is not available at the expected location, and the client must redirect.
- 400-499: Client Error - an invalid request was sent to the server.
- 500-599: Server Error - the server is overwhelmed or unreachable.
CRUD (create, read, update, delete) is a model defining the most basic API actions for persistant storage.
- Create
- 200 - OK
- 201 - Created
- 202 - Accepted
- 303 - See Other
- Read
- 200 - OK
- 206 - Partial Content
- 300 - Multiple Choices
- 304 - Not Modified
- 307 - Temporary Redirect
- 308 - Permanent Redirect
- Update
- 200 - OK
- 202 - Accepted
- 204 - No Content
- Delete
- 200 - OK
- 202 - Accepted
- 204 - No Content
- API Changes
- 307 - Temporary Redirect
- 308 - Permanent Redirect
- Multiple Endpoints for One Resource
Errors are another important section of status codes
- Wrong URL
- 307 - Temporary Redirect
- 308 - Permanent Redirect
- 404 - Not Found
- 405 - Method Not Allowed
- 406 - Not Acceptable
- 410 - Gone
- 414 - Request URI Too Long
- 501 - Not Implemented
- No Permissions
- 401 - Unauthorized
- 403 - Forbidden
- 404 - Not Found
- 100s, the server is acknowledging your request - 200s, the server has accepted your request - 300s, the server needs you to go somewhere else - 400s, the client has messed something up - 500s, the server has messed something up.
- 202 is Accepted
- 308 is a permanent redirect
- If an update didn’t return data, you would return 204.
- If a resource used to exist, but no longer does you would use 410.
- Forbidden is 403
Build a Rest API
- Because we don’t want the database link pushed to github.
- Middleware runs between when the server recieves a request and passes it to a route.
- Lets the server accept json as a body.
- It is a parameter.
- Patch only updates based on what is passed in, while Put updates everything.
- You put in a default key in the object.
- 500 meanse there’s an error on the server.
- 201 meanse successfully created an object, 200 is a more generic success.
Things I Want to Know More About
[< table of contents]
[< home]