vindec-nhtsa
v2.0.0
Published
A VDS Decoding Plugin for vindec VIN Decoder
Downloads
6
Maintainers
Readme
DEPRECATION NOTICE
This module is no longer under active development.
NOTE: breaking changes were introduced while refactoring vindec.
I am in the process of moving this repo's functionality to the original vindec repo and decoupling this plugin architecture. Older versions of vindec (<=2.1.3) should still work.
vindec-nhtsa
A Vindec plugin that returns a vin object with a property called fetch that is a pending Promise that, when settled, fetches the NHTSA data from a vehicle's manufacture year and VIN.
Install via npm (or yarn)
Returns original, vindec object (mutated)
When the decode method is called on a VIN, it returns the standard vindec decoded object, but it also includes the URL of the API and the response data. I may still sanitize some of the data returned, but I may leave it as-is. Any suggestions are greatly appreciated.
// create and mutate
const vindec = require('vindec');
const nhtsa = require('vindec-nhtsa')(vindec);
// decode and validate
let vin = nhtsa.decode('12345678901234567', (error, data) => {
if (error) {
console.log('Error: ', err.message);
}
return data;
});
// settle pending promise
vin.fetch().then((data) => {
// fulfilled
vin.nhtsa = JSON.parse(data);
console.log('--NHTSAResults:\n', vin.nhtsa.Results);
}).catch((error) => {
// rejected
console.log('Danger, Will Robinson! Error:\n', error);
});