0
Upload image
One script reply has been approved by the moderators Verified
Created by hugo697 208 days ago Viewed 13474 times
0
Submitted by hugo697 Bun
Verified 208 days ago
1
//native
2
type Adhook = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Adhook,
8
	adhookToken: string,
9
	body: {
10
		promotionId?: string
11
		imageUrl?: string
12
		accountId?: string
13
		subtenantId?: string
14
	}
15
) {
16
	const url = new URL(`https://app.adhook.io/v1/promotions/facebook/image`)
17

18
	const response = await fetch(url, {
19
		method: 'POST',
20
		headers: {
21
			adhookToken: adhookToken,
22
			Authorization: `Bearer ${auth.token}`,
23
			'Content-Type': 'application/json'
24
		},
25
		body: JSON.stringify(body)
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