Important: This documentation applies to v2 of this package.
For v3 docs see vpic.shaggytech.com

Class

Fetch

api/Fetch.Fetch(userConfigopt)

Class wrapper containing API wrapper HTTP Fetch logic.

Static Methods:

Constructor

# new Fetch(userConfigopt)

Parameters:
Name Type Attributes Description
userConfig FetchConfig <optional>

User configuration options to construct the class with.

View Source api/Fetch.ts, line 56

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 true to add empty parameter values to the returned query string.

  • Given params of {paramName: ""} , setting this to true will use 'paramName=' in the final query string.
  • GetCanadianVehicleSpecifications is the only API Action that requires this functionality.

View Source api/Fetch.ts, line 86

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.

Parameters:
Name Type Attributes Description
url string

URL to fetch data from.

options FetchRequestOptions <optional>

Fetch options.

View Source api/Fetch.ts, line 113

Response from the API.

Promise.<module:api/Fetch.ApiResponse>