WebAPI
A helper class for working with the REST API.
In all cases, no attempt is made to trap errors. RequestPromises are returned from each method. It's up to the caller to handle rejection.
Example:
import WebAPI from "./WebAPI";
WebAPI.get("/admin/products.json")
.then(json => console.log(json))
.catch(error => console.log(error.message));
Method Summary
Public Methods | ||
public |
delete(url: string, options: object): RequestPromise Performs a DELETE request for the given URL and options |
|
public |
get(url: string, options: object): RequestPromise Performs a GET request for the given URL and options |
|
public |
post(url: string, resource: object, options: object): RequestPromise Performs a POST request for the given URL and options, passing the resource as the request body |
|
public |
put(url: string, resource: object, options: object): RequestPromise Performs a PUT request for the given URL and options, passing the resource as the request body |
Public Methods
public delete(url: string, options: object): RequestPromise source
Performs a DELETE request for the given URL and options
public get(url: string, options: object): RequestPromise source
Performs a GET request for the given URL and options
public post(url: string, resource: object, options: object): RequestPromise source
Performs a POST request for the given URL and options, passing the resource as the request body
public put(url: string, resource: object, options: object): RequestPromise source
Performs a PUT request for the given URL and options, passing the resource as the request body