Coder Social home page Coder Social logo

unit-6-rest-json-server's Introduction

Unit-6-REST-JSON-Server:

Lesson Overview:

  • 00:00 - 00:05 - Review CRUD
  • 00:05 - 00:15 - REST
  • 00:15 - 00:30 - REST(ful) APIs
  • 00:30 - 00:40 - Request/Response Cycle
  • 00:40 - 01:00 - JSON Server Mini Lab

Objectives:

  • Students should be able to:
    • Understand the REST Paradigm
    • Identify REST API's
    • Create examples of REST URLs
    • Understand the request/response cycle
    • Get started by creating their own REST(ful) API through the use of JSON Server

Key Questions:

  • What is REST?
  • What are REST Principles?
  • Why do we use REST?
  • How can we represent complex relationships with REST?

Terms To Know:

  • CRUD: Create, Read, Update, Delete
  • REST: Representational State Transfer
  • API: Application Programming Interfaces

REST API:

REST, or Representational State Transfer, is an architectural style that is meant to make communication between systems easier. With REST, we can separate the client and server! This is because as long as both systems use the same agreed-upon communications, they can work independently from each other; in this case, it would be RESTful conventions. By creating RESTful endpoints, the client and server hit the same endpoints, perform the same actions(CRUD operations), and respond similarly.

Request/Response Cycle:

  • A client must first send a request to the server through the RESTful API.
    • A request consists of an HTTP verb, a header, a path, and an optional message body(depending on the verb)!
  • The web server will then send a message to the database.
  • The database will respond and send back some information to the server.
    • If the request is GET, the database may not change but instead return the information necessary.
    • If the request is POST, UPDATE, or DELETE, the database may respond with the new information!
  • The web server, using the RESTful API, will then display a change in the client.

Example of RESTful Conventions:

Below is a table that shows the ways in which the specific HTTP method is related to a specific CRUD action. In addition, there is information on the REST convention! The convention is /pluralNane/:id. The id is only needed when we are specifying which item we are updating. The first 6 items in the table are fairly simple; however, relationships can sometimes be complex, and we will need to show that as well. The last 2 are examples of relationships that are more complex!

HTTP Method URL Path CRUD Action Result
GET /books READ Responds with all books
GET /books/:id READ Responds with the book that corresponds with that id
POST /books CREATE Adds a book to inventory and respond with a newly added book
PATCH /books/:id UPDATE Updates the detail of the specific book and responds with the updated book
PUT /books/:id UPDATE Completely updates the details of a specific book and responds with the new book's information
DELETE /books/:id DELETE Removes the book from inventory
GET /authors/:id/books READ Responds with all of the books from the specified author
GET authors/:id/books/:id READ Responds with a specified book from the specified author

Additional Resources:

Useful Information to check out:

unit-6-rest-json-server's People

Contributors

itzel01 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.