Fetcher
Extends:
Performs REST requests to constant url.
Example:
import {Fetcher} from 'fetchers';
const fetcher = new Fetcher('http://example.com', {credentials: 'include'});
fetcher.get()
.then(response => response.ok ? response.json() : response.statusText)
.then(data => console.log(data));
Constructor Summary
Public Constructor | ||
public |
constructor(url: String, defaultOptions: RequestOptions, handlers: Handlers) |
Method Summary
Public Methods | ||
public |
async delete(body: *, options: RequestOptions): Promise<Response> Performs DELETE request. |
|
public |
async get(options: RequestOptions): Promise<Response> Performs GET request. |
|
public |
async head(body: *, options: RequestOptions): Promise<Response> Performs HEAD request. |
|
public |
async patch(body: *, options: RequestOptions): Promise<Response> Performs PATCH request. |
|
public |
async post(body: *, options: RequestOptions): Promise<Response> Performs POST request. |
|
public |
async put(body: *, options: RequestOptions): Promise<Response> Performs PUT request. |
Inherited Summary
From class PathFetcher | ||
public |
async delete(path: String, body: *, options: RequestOptions): Promise<Response> Performs DELETE request to url path. |
|
public |
async get(path: String, options: RequestOptions): Promise<Response> Performs GET request to url path. |
|
public |
async head(path: String, body: *, options: RequestOptions): Promise<Response> Performs HEAD request to url path. |
|
public |
async patch(path: String, body: *, options: RequestOptions): Promise<Response> Performs PATCH request to url path. |
|
public |
async post(path: String, body: *, options: RequestOptions): Promise<Response> Performs POST request to url path. |
|
public |
async put(path: String, body: *, options: RequestOptions): Promise<Response> Performs PUT request to url path. |
Public Constructors
public constructor(url: String, defaultOptions: RequestOptions, handlers: Handlers) source
Override:
PathFetcher#constructorParams:
Name | Type | Attribute | Description |
url | String | url used for every request |
|
defaultOptions | RequestOptions |
|
default options used for every request |
handlers | Handlers |
|
functions for processing every request and response |
Public Methods
public async delete(body: *, options: RequestOptions): Promise<Response> source
Performs DELETE request.
Override:
PathFetcher#deleteParams:
Name | Type | Attribute | Description |
body | * |
|
request body |
options | RequestOptions |
|
custom options |
public async get(options: RequestOptions): Promise<Response> source
Performs GET request.
Override:
PathFetcher#getParams:
Name | Type | Attribute | Description |
options | RequestOptions |
|
custom options |
public async head(body: *, options: RequestOptions): Promise<Response> source
Performs HEAD request.
Override:
PathFetcher#headParams:
Name | Type | Attribute | Description |
body | * |
|
request body |
options | RequestOptions |
|
custom options |
public async patch(body: *, options: RequestOptions): Promise<Response> source
Performs PATCH request.
Override:
PathFetcher#patchParams:
Name | Type | Attribute | Description |
body | * |
|
request body |
options | RequestOptions |
|
custom options |
public async post(body: *, options: RequestOptions): Promise<Response> source
Performs POST request.
Override:
PathFetcher#postParams:
Name | Type | Attribute | Description |
body | * |
|
request body |
options | RequestOptions |
|
custom options |
public async put(body: *, options: RequestOptions): Promise<Response> source
Performs PUT request.
Override:
PathFetcher#putParams:
Name | Type | Attribute | Description |
body | * |
|
request body |
options | RequestOptions |
|
custom options |