Check the status of a specified VAT number.
1
type Abstractapi = {
2
apiKey: string
3
}
4
5
export async function main(resource: Abstractapi, vatNumber: string) {
6
const queryParams = new URLSearchParams({
7
api_key: resource.apiKey,
8
vat_number: vatNumber
9
})
10
11
const endpoint = `https://vat.abstractapi.com/v1/validate?${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