Primeiro, instale nossa biblioteca com npm:
$ npm i gender-api.com-client --save
import {Client as GenderApiClient, ResultSingleName} from "gender-api.com-client";
const genderApiClient = new GenderApiClient("your API key");
try {
genderApiClient.getByFirstName('theresa', (response: ResultSingleName) => {
console.log(response.gender);
console.log(response.accuracy);
});
genderApiClient.getByFirstNameAndCountry('john', 'US', (response: ResultSingleName) => {
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