0
Validate Email
One script reply has been approved by the moderators Verified

Check the status of a specified email address.

Created by hugo697 56 days ago Viewed 13 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 56 days ago
1
type Abstractapi = {
2
	apiKey: string
3
}
4

5
export async function main(resource: Abstractapi, email: string) {
6
	const queryParams = new URLSearchParams({
7
		api_key: resource.apiKey,
8
		email,
9
		auto_correct: 'false'
10
	})
11

12
	const endpoint = `https://emailvalidation.abstractapi.com/v1?${queryParams.toString()}`
13

14
	const response = await fetch(endpoint, {
15
		method: 'GET'
16
	})
17

18
	if (!response.ok) {
19
		throw new Error(`HTTP error! status: ${response.status}`)
20
	}
21

22
	const data = await response.json()
23

24
	return data
25
}
26