httpquest v1.0.3
httpquest
A wrapper to simplify the fetch API.
Installation
npm install httpquest
Reference
httpRequest
Syntax:
import httpRequest from 'httpquest';
httpRequest(url, method, body, options)
.then(json => console.log(json))
.catch(error => console.error(error));url
Type: String
A string representing the URL of the request.
method
Type: String
A case-insensitive string representing the method of the request.
'HEAD''GET''POST''PUT''PATCH''DELETE'
body (depending on method, optional)
Type: Object
An object of either FormData or JSON required for only POST, PUT and PATCH requests which contain the payload data.
options (optional)
Type: Object
An object that contains other paremeters that the Fetch API accepts.
Example:
{
credentials: 'include',
headers: { xsrfToken: token },
params: { search: 'dog' }
}get
Syntax:
import { get } from 'httpquest';
get(url, options)
.then(json => console.log(json))
.catch(error => console.error(error));url
Type: String
A string representing the URL of the request.
options (optional)
Type: Object
An object that contains other paremeters that the Fetch API accepts.
Example:
{
credentials: 'include',
headers: { xsrfToken: token },
params: { search: 'dog' }
}post
Syntax:
import { post } from 'httpquest';
post(url, body, options)
.then(json => console.log(json))
.catch(error => console.error(error));url
Type: String
A string representing the URL of the request.
body (depending on method, optional)
Type: Object
An object of either FormData or JSON required for only POST, PUT and PATCH requests which contain the payload data.
options (optional)
Type: Object
An object that contains other paremeters that the Fetch API accepts.
Example:
{
credentials: 'include',
headers: { xsrfToken: token },
params: { search: 'dog' }
}put
Syntax:
import { put } from 'httpquest';
put(url, body, options)
.then(json => console.log(json))
.catch(error => console.error(error));url
Type: String
A string representing the URL of the request.
body (depending on method, optional)
Type: Object
An object of either FormData or JSON required for only POST, PUT and PATCH requests which contain the payload data.
options (optional)
Type: Object
An object that contains other paremeters that the Fetch API accepts.
Example:
{
credentials: 'include',
headers: { xsrfToken: token },
params: { search: 'dog' }
}patch
Syntax:
import { patch } from 'httpquest';
patch(url, body, options)
.then(json => console.log(json))
.catch(error => console.error(error));url
Type: String
A string representing the URL of the request.
body (depending on method, optional)
Type: Object
An object of either FormData or JSON required for only POST, PUT and PATCH requests which contain the payload data.
options (optional)
Type: Object
An object that contains other paremeters that the Fetch API accepts.
Example:
{
credentials: 'include',
headers: { xsrfToken: token },
params: { search: 'dog' }
}delete
Syntax:
import { delete } from 'httpquest';
delete(url, options)
.then(json => console.log(json))
.catch(error => console.error(error));url
Type: String
A string representing the URL of the request.
body (depending on method, optional)
Type: Object
An object of either FormData or JSON required for only POST, PUT and PATCH requests which contain the payload data.
options (optional)
Type: Object
An object that contains other paremeters that the Fetch API accepts.
Example:
{
credentials: 'include',
headers: { xsrfToken: token },
params: { search: 'dog' }
}