46
loading...
This website collects cookies to deliver better user experience
REST
is an acronym for Representational State Transfer ProtocolGET, POST or PUT
is fundamental to REST apis and are among the methods that can be specified when making a request to a REST api. The server looks at the request made, it will check the method that was called with the request and call the appropriate handler to process the request. The server can handle the request and send some data back if the need be. One thing with RESTful apis is that you can only make a request to a particular url with a specific method although an endpoint can handle request with different methods. For a particular endpoint the API will always handle the request the same way and will always return the same shape or format of data back to the client. query strings
. a typical request to a REST api would look like the example provided below;POST http://localhost:3000/book/
Content-Type: application/json
{
"name": "The God's are not to blame",
"author": "Ola Rotimi"
}
POST
request and also send some mock JSON data with it, this is to give you a basic idea of how REST apis work. We can set more than one type of header on the request if there is a requirement for it.GET http://localhost:3000/book?id=2345698
accept: application/json
API-KEY: 234WES7Y5WEQ
PATCH
and PUT
request are quite similar. GET
requests. They can be cached, bookmarked, and can even be stored in a history. All these are easy because every request to a REST api is destined for a particular url and has a particular method associated with that method, another obvious cool thing about REST apis.type User{
_id: ID!,
name: String,
age: Int,
friends: [User!]
}
query {
user {
name,
age,
friends {
name,
_id
}
}
}
mutation
for changing the state of our data