0
List VAT Categories
One script reply has been approved by the moderators Verified

List the latest VAT rates, including the reduced rates for certain categories, for a specific country.

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

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

11
	const endpoint = `https://vat.abstractapi.com/v1/categories?${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