globe-pointerRequests

ShapeRQ supports all HTTP methods:

  • GET - get data

  • POST - send data

  • PATCH - update data with partial overwrite of the object

  • PUT - update data with full overwrite of the object

  • DELETE - delete the object

  • HEAD - get headers, check resource exictence

  • OPTIONS - get inforamtion about supported methods


import { 
    httpGet, httpPost, httpPut, httpPatch,
    httpDel, head, options
} from "shape-rq"

Request without body


httpGet<UserType>("MyAPI", "users/")
    .then(data => {
    console.log(data)
})
// OR
const res = await httpGet("MyAPI", "users/")
console.log(res)
chevron-rightRequest without body also includes HEAD and OPTIONS.hashtag

These types of requests take only two parameters as arguments - the key from APIs and the endpoint of the request.


Requests with body

A simple template of POST request, there three paramters:

  • API

  • endpoint

  • options -> body

In the body, we pass the data of our request, what we send to the server, in the form of a record <string, any> or FormData or just string

Last updated