0

Get Attribute By Id

by
Published Oct 11, 2024

This endpoint retrieves the details of a specific attribute by ID.

Script zixflow Verified

The script

Submitted by hugo697 Bun
Verified 606 days ago
1
//native
2

3
type Zixflow = {
4
	apiKey: string
5
}
6

7
export async function main(
8
	resource: Zixflow,
9
	target: 'collection' | 'list',
10
	targetId: string,
11
	attributeId: string
12
) {
13
	const endpoint = `https://api.zixflow.com/api/v1/attributes/${target}/${targetId}/${attributeId}`
14

15
	const response = await fetch(endpoint, {
16
		method: 'GET',
17
		headers: {
18
			Authorization: `Bearer ${resource.apiKey}`
19
		}
20
	})
21

22
	if (!response.ok) {
23
		throw new Error(`HTTP error! status: ${response.status}`)
24
	}
25

26
	const data = await response.json()
27

28
	return data
29
}
30