Installier zuerst unsere Library mit 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);
}
Link zur Client-Dokumentation auf Github:
https://github.com/markus-perl/gender-api-client-npm