Primero instala nuestra biblioteca con 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);
}
Vea la documentación completa del cliente aquí:
https://github.com/markus-perl/gender-api-client-npm