0
Get posts to be published manually
One script reply has been approved by the moderators Verified
Created by hugo697 14 days ago Viewed 1196 times
0
Submitted by hugo697 Bun
Verified 14 days ago
1
//native
2
type Adhook = {
3
	token: string
4
}
5

6
export async function main(auth: Adhook, subtenantId: string | undefined, Origin: string) {
7
	const url = new URL(`https://app.adhook.io/v1/posts/publishManually`)
8

9
	for (const [k, v] of [['subtenantId', subtenantId]]) {
10
		if (v !== undefined && v !== '' && k !== undefined) {
11
			url.searchParams.append(k, v)
12
		}
13
	}
14

15
	const response = await fetch(url, {
16
		method: 'GET',
17
		headers: {
18
			Authorization: `Bearer ${auth.token}`,
19
			Origin: Origin
20
		},
21
		body: undefined
22
	})
23

24
	if (!response.ok) {
25
		const text = await response.text()
26
		throw new Error(`${response.status} ${text}`)
27
	}
28

29
	return await response.json()
30
}
31