-
Notifications
You must be signed in to change notification settings - Fork 0
Client
import { Client } from 'awi'This is the interface implemented by the Awi class.
use (interceptor: Interceptor, priority?: number) : Clientsend<T extends Response> () : Promise<T>get<T extends Response> (path?: string) : Promise<T>delete<T extends Response> (path?: string) : Promise<T>head<T extends Response> (path?: string) : Promise<T>options<T extends Response> (path?: string) : Promise<T>post<T extends Response> (path?: string, body?: any) : Promise<T>put<T extends Response> (path?: string, body?: any) : Promise<T>patch<T extends Response> (path?: string, body?: any) : Promise<T>body<T> (path?: string) : Promise<T>optional<T> (path?: string) : Promise<Optional<T>>
Provides a way to intercept any request directly. The callback takes in an instance of Request and alters its contents. The return value is disregarded.
Parameters
-
interceptor: Interceptor- The function that alters the event -
priority?: number- The priority of the interceptor, interceptors with higher priority are executed first
Returns
Client - The instance for chaining
Perform the transformed request.
Type Parameters
-
T extends Response- The desired response type
Returns
Promise<T> - The desired response
Throws
-
HttpException- If something goes wrong when executing the request
Get, delete, head and options request execution shorthands.
Parameters
-
path?: string- The path to use for the request
Type Parameters
-
T extends Response- The desired response type
Returns
Promise<T> - The desired response
Throws
-
HttpException- If something goes wrong when executing the request
Post, put and patch request execution shorthands.
Parameters
-
path?: string- The path to use for the request -
body?: any- he body to be sent with the request
Type Parameters
-
T extends Response- The desired response type
Returns
Promise<T> - The desired response
Throws
-
HttpException- If something goes wrong when executing the request
A request helper that only returns the body of the response.
Parameters
-
path?: string- The path to use for the request
Type Parameters
-
T- The desired response body type
Returns
Promise<T> - The desired response
Throws
-
HttpException- If something goes wrong when executing the request
A request helper that only returns the body of the response and instead of rejecting the promise, it resolves an Optional<T>.
Parameters
-
path?: string- The path to use for the request
Type Parameters
-
T- The desired response body type
Returns
Promise<Optional<T>> - The desired response wrapped in an optional
Throws
-
HttpException- If something goes wrong when executing the request