HTTP Methods and CRUD Operations2:08 with Treasure Porth
CRUD operations and how they relate to HTTP methods.
Think about the web applications you interact with on a daily basis. 0:00 We use applications for huge variety of things, but at their simplest, 0:04 many follow a common pattern, create, read, update and delete. 0:08 Take a blog or a popular social media site, for example. 0:12 You can usually make a new post, that's create, view other posts, 0:15 that's read, edit a post, that's update, or delete a post, that's delete. 0:20 This pattern is commonly known by the acronym CRUD, create, read, update and 0:25 delete. 0:30 REST APIs allow a client to manipulate data using actions that map closely to 0:30 the idea of CRUD. 0:35 These actions are get, post, put and delete. 0:36 Get, post, put, and delete are known as HTTP verbs or HTTP methods. 0:40 There are actually many more HTTP methods, but 0:45 we'll concentrate on these four because they're the most commonly used. 0:48 See the teacher's notes if you want to learn more about HTTP protocol, but 0:51 basically it's an agreed upon standard for communication over the Internet. 0:55 Information in a REST API is typically organized using nouns that describe 0:59 what the data represents, nouns like users, posts, movies, or recipes. 1:04 Using HTTP methods and API nouns, a client can tell a REST API what information 1:08 it wants and what it wants to do with that information. 1:13 As an example, If the client sends a get request to the resource/movies, 1:17 it means it expects to read or view data representing a collection of movies. 1:21 A post request means it wants to create a new movie. 1:26 Put means it wants to update an existing movie, and 1:29 delete means it wants to, you got it, delete a movie. 1:33 When we write an API, 1:36 we're essentially programming responses to various HTTP requests for resources. 1:38 Through code, we say to our express application, 1:43 when a client makes a get request to the resource/movies, 1:45 respond with a JSON object containing a list of movies. 1:49 At the core, that's really all an express API does. 1:52 It takes in requests, and responds with JSON objects. 1:55 I've just thrown a lot at you that may seem unfamiliar, but stick with it. 1:59 In the next video, 2:02 we'll build a simplified example of how this all comes together in code. 2:03 Are you ready? 2:07
You need to sign up for Treehouse in order to download course files.Sign up