FetchUtil
A thin wrapper around the Fetch API which provides functionality to automatically request a new access token if an existing one has expired.
Static Method Summary
Static Public Methods | ||
public static |
formatErrorResponse(response: Response): Promise Wraps an error response from an API call in an ApiError object so that consuming code has more flexibility to determine how to handle the error. |
|
public static |
nprApiFetch(url: string, options: Object): Promise<Object> Primary workhorse for interacting with the NPR One APIs. |
Static Public Methods
public static formatErrorResponse(response: Response): Promise source
Wraps an error response from an API call in an ApiError object so that consuming code has more
flexibility to determine how to handle the error. To be clear: this function returns a Promise that always
rejects, but it may or may not have the deserialized JSON body based on whether response.json()
succeeded or
failed (the latter is usually an indicator that the response had an empty body).
Params:
Name | Type | Attribute | Description |
response | Response |