Validate IBAN
One script reply has been approved by the moderators Verified

Determine the validity of the International Bank Account Number.

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

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

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

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

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

21
	const data = await response.json()
22

23
	return data
24
}
25