Primeiro, instale nossa biblioteca com npm:
$ npm i gender-api.com-client --save
try {
var GenderApi = require('gender-api.com-client');
var genderApiClient = new GenderApi.Client('your api key');
genderApiClient.getByFirstName('theresa', function (response) {
console.log(response.gender);
console.log(response.accuracy);
});
genderApiClient.getByFirstNameAndCountry('john', 'US', function (response) {
console.log(response.gender);
console.log(response.accuracy);
});
}
catch(e) {
console.log('Error:', e);
}
Consulte a documentação completa do cliente aqui:
https://github.com/markus-perl/gender-api-client-npm