peru-dni
Node module to fetch real name from peruvian's dni
How to Install:
Using npm:
> $ npm install peru-dni --save
How to use:
(Nodejs example)
const perudni = ; // using Promisesperudni ; // using async/await { try let data = await perudni; console; catch err console; };
getNameFromDNI() If everything works well it will return an object like this:
dni: '00000003' fullname: 'CARLOTA MEZA DE RUIZ' lastname: 'MEZA' secondlastname: 'DE RUIZ' name: 'CARLOTA'
If there's no one with that DNI
dni: '00000000' error: 'DNI no encontrado en Padrón Electoral' message: 'Cant get name from that DNI'
If there's no connection with the external public API, it will throw an error
'Fetch failed'
Run tests with
$ npm run test