GENDER API TYPESCRIPT
Installeer eerst onze bibliotheek met 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); //female
console.log(response.accuracy); //98
});
genderApiClient.getByFirstNameAndCountry('john', 'US', (response: ResultSingleName) => {
console.log(response.gender); //male
console.log(response.accuracy); //99
});
}
catch(e) {
console.log('Error:', e);
}