API Fetch Logic.
Module Exports:
- Class: Fetch
- Constant: BASE_URL
- Constant: DEFAULT_CONFIG
Types
- Type: ApiResponse
- Type: FetchConfig
- Type: FetchRequestOptions
- Type: FetchRequestBodyTypes
- Type: FetchResponse
- Type: NhtsaResponse
Classes
Members
# inner constant BASE_URL
Default Fetch base URL string
- Default Value:
- 'https://vpic.nhtsa.dot.gov/api/vehicles'
# inner constant DEFAULT_CONFIG
Default Fetch configuration options
Properties:
Name | Type | Default | Description |
---|---|---|---|
apiResponseFormat |
string | json | |
baseUrl |
string | BASE_URL | Default: BASE_URL |
options |
FetchRequestOptions | {method:"GET"} |
Type Definitions
# ApiResponse
Complete response returned by module:api/Fetch.Fetch#get
.
Properties:
Name | Type | Description |
---|---|---|
Count |
number | The number of items returned in the Results object. |
Message |
string | A message describing the Results. |
SearchCriteria |
string | Search terms (VIN, WMI, etc) used in the request URL. |
Results |
Array.<any> | An array of Results returned by NHSTA, specific to each individual API Action. |
FetchResponse |
FetchResponse | Fetch API Response Properties. |
- See:
-
module:api/Fetch.NhtsaResponse
module:api/Fetch.FetchResponse
# FetchConfig
Used when instantiating a Fetch class or related subclass.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
apiResponseFormat |
string |
<optional> |
Requested response format from the NHSTA API (hardcoded to 'json' for now). |
baseUrl |
string |
<optional> |
Base of the URL to build fetch URLs from. |
options |
FetchRequestOptions |
<optional> |
Options object provided as the 2nd argument to |
# FetchRequestOptions
Options object provided as the 2nd argument to module:api/Fetch.Fetch#get
.
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
method |
string |
<optional> |
HTTP request method - Default: "GET". |
body |
string | FetchRequestBodyTypes |
<optional> |
HTTP request body - FetchRequestBodyTypes. |
headers |
Record.<string, string> | Headers |
<optional> |
Object, Headers - Default: {}. |
credentials |
'omit' | 'same-origin' | 'include' |
<optional> |
Default: "omit" - Authentication credentials mode.,
|
# FetchResponse
Fetch API Response properties.
Properties:
Name | Type | Description |
---|---|---|
headers |
Headers | The Headers object associated with the response. |
ok |
boolean | A boolean indicating whether the response was successful (status in the range 200–299) or not. |
redirected |
boolean | Indicates whether or not the response is the result of a redirect (that is, its URL list has more than one entry). |
status |
number | The status code of the response. (This will be 200 for a success). |
statusText |
string | The status message corresponding to the status code. (e.g., OK for 200). |
url |
string | The URL of the response. |
# NhtsaResponse
Response data returned from the NHSTA API.
Properties:
Name | Type | Description |
---|---|---|
Count |
number | The number of items returned in the Results object. |
Message |
string | A message describing the Results. |
SearchCriteria |
string | Search terms (VIN, WMI, etc) used in the request URL. |
Results |
Array.<any> | An array of Results returned by NHSTA, specific to each individual API Action. |