@shaggytools/nhtsa-api-wrapper - v3.0.4 / Exports / api/useNHTSA
Module: api/useNHTSA
Table of contents
Type Aliases
Functions
Type Aliases
CreateUrlOptions
Ƭ CreateUrlOptions: Object
Type declaration
Name | Type |
---|---|
allowEmptyParams? | boolean |
endpointName | string |
includeQueryString? | boolean |
params? | QueryStringParams |
path? | string |
saveUrl? | boolean |
Defined in
Functions
useNHTSA
▸ useNHTSA(): Object
useNHTSA
returns a composable object containing helper functions for working with the VPIC API. It is used internally by the package and by users to make direct requests to the VPIC API.
It returns an object containing methods for making HTTP requests to the VPIC API. All request methods return a Promise that resolves to an object containing the full response data.
The functions returned by the composable are:
createCachedUrl
- Builds the URL string and stores it in internal stategetCachedUrl
- Gets the URL stored in internal statesetCachedUrl
- 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
Returns
Object
Name | Type |
---|---|
clearCachedUrl | () => string |
createCachedUrl | (input : string | CreateUrlOptions ) => string |
createPostBody | (data : string ) => string |
createUrl | (options : CreateUrlOptions ) => string |
get | <T>(url? : string | CreateUrlOptions , options? : RequestInit & { saveUrl? : boolean }) => Promise <NhtsaResponse <T >> |
getCachedUrl | () => string |
post | <T>(url? : string | CreateUrlOptions , options? : RequestInit & { saveUrl? : boolean }) => Promise <NhtsaResponse <T >> |
setCachedUrl | (url : string ) => string |