0
Upload bookmark asset file
One script reply has been approved by the moderators Verified
Created by hugo697 58 days ago Viewed 1254 times
0
Submitted by hugo697 Bun
Verified 58 days ago
1
//native
2
type Actimo = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Actimo,
8
	body: { files?: string[]; path?: string; youtube?: number }
9
) {
10
	const url = new URL(`https://actimo.com/api/v1/assets/bookmark`)
11

12
	const formData = new FormData()
13

14
	for (const [k, v] of Object.entries(body)) {
15
		if (v !== undefined && v !== '') {
16
			formData.append(k, String(v))
17
		}
18
	}
19

20
	const response = await fetch(url, {
21
		method: 'POST',
22
		headers: {
23
			'api-key': auth.apiKey
24
		},
25
		body: formData
26
	})
27

28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32

33
	return await response.json()
34
}
35