//native
type Greip = {
apiKey: string;
};
/**
* Validate email addresses and retrieve additional information
* This method provides an additional layer of validation for your system. While validating email syntax is important, it is not sufficient.
This method goes beyond syntax validation by checking the domain’s validity, the availability of the Mail Service, detecting Disposable Email (Temporary Emails), etc. By utilising this method, you can ensure a more thorough validation process for email addresses.
*/
export async function main(
auth: Greip,
email: string,
format: string | undefined,
userID: string | undefined,
mode: string | undefined,
callback: string | undefined,
) {
const url = new URL(`https://greipapi.com/scoring/email`);
for (const [k, v] of [
["email", email],
["format", format],
["userID", userID],
["mode", mode],
["callback", callback],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago