6.0.7 • Published 5 years ago

peru-dni v6.0.7

Weekly downloads
2
License
GNU V3
Repository
github
Last release
5 years ago

peru-dni

npm npm bundle size GitHub stars

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 = require('peru-dni');

// using Promises
perudni.getNameFromDNI(71747104)
    .then(data => {
        console.log('Real name is ' + data.fullname);
    })
    .catch(err => {
        console.log('Something went wrong ', err);
    });

// using async/await
async function main() {
    try {
        let data = await perudni.getNameFromDNI(71747104);

        console.log(`${data.dni} > ${data.fullname}`);
    } catch (err) {
        console.log('Something went wrong ', err);
    }
}
main();
    

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

6.0.7

5 years ago

6.0.6

5 years ago

6.0.5

5 years ago

3.0.0

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago