2.0.0 • Published 5 years ago

vindec-nhtsa v2.0.0

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

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)

NPM

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);
});
2.0.0

5 years ago

1.1.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago