useNHTSA Composable Function
const useNHTSA: () => {
setCachedUrl: (url: string) => string
getCachedUrl: () => string
clearCachedUrl: () => string
createCachedUrl: (input: CreateUrlOptions | string) => string
createUrl: (options: CreateUrlOptions) => string
createPostBody: (data: string) => string
get: <T>(
url?: string | CreateUrlOptions,
options?: RequestInit & {
saveUrl?: boolean
}
) => Promise<NhtsaResponse<T>>
post: <T>(
url?: string | CreateUrlOptions,
options?: RequestInit & {
saveUrl?: boolean
}
) => Promise<NhtsaResponse<T>>
}
useNHTSA
returns an object containing helper functions for working with the NHTSA VPIC API. It is used internally by the package and by users to make direct requests to the VPIC API.
It contains functions for making HTTP requests to the VPIC API. All request methods return a Promise that resolves to an object containing the full response data. See the VPIC API Response page for more info on the full response returned by the request functions.
The functions returned by the composable are:
createCachedUrl
- Builds the URL string and stores it in internal stategetCachedUrl
- Gets the URL stored in internal state```**setCachedUrl
- Directly sets the URL internal state, does not check if URL is validclearCachedUrl
- Clears the URL stored in internal statecreateUrl
- Returns a built URL string but does not store it in internal statecreatePostBody
- Creates a POST body string from an object of key/value pairsget
- Makes a GET request, uses the internal url variable if no URL is providedpost
- Makes a POST request, uses the internal url variable if no URL is provided