20 lines
581 B
JavaScript
20 lines
581 B
JavaScript
const fetch = require('node-fetch');
|
|
|
|
const baseUrl = 'https://vin01.ru/v2';
|
|
|
|
class Vin01Provider {
|
|
static async getVin(number, token) {
|
|
let url = `${baseUrl}/getVin.php?key=${token}&gosNumber=${encodeURIComponent(number)}`;
|
|
let result = await fetch(url);
|
|
let json = await result.json();
|
|
if(json.success && json.code == 200) {
|
|
return json.data.vin;
|
|
} else {
|
|
console.log('==========================================================');
|
|
console.log(JSON.stringify(json));
|
|
throw Error('Vin01 provider failed to get VIN');
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = Vin01Provider; |