Constructor
# new Fetch(userConfigopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
userConfig |
FetchConfig |
<optional> |
User configuration options to construct the class with. |
Methods
# async buildQueryString(params, allowEmptyStringValuesopt) → {Promise.<string>}
Builds a query string from QueryStringParameters.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
params |
QueryStringParameters | Object containing Key:Value pairs to build the URL query string with. |
||
allowEmptyStringValues |
boolean |
<optional> |
false | Set to
|
A formatted NHSTA.dot.gov Vehicles API query string.
Promise.<string>
# async get(url, optionsopt) → {Promise.<module:api/Fetch.ApiResponse>}
Uses the isomorphic-unfetch
npm package to send HTTP requests and retrieve data from an API.
- Switches between unfetch & node-fetch for client & server.
- 2.5 kB unpacked size
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | URL to fetch data from. |
|
options |
FetchRequestOptions |
<optional> |
Response from the API.
Promise.<module:api/Fetch.ApiResponse>