Get Page Content

Get static content from a static page. If you do not provide a Locale ID in your request, the response will return any content that can be localized from the Primary locale Required scope | `pages:read`

Script webflow Verified

by hugo697 ยท 11/5/2024

The script

Submitted by hugo697 Bun
Verified 563 days ago
1
//native
2
type Webflow = {
3
	token: string
4
}
5

6
export async function main(
7
	auth: Webflow,
8
	page_id: string,
9
	locale: string | undefined,
10
	limit: string | undefined,
11
	offset: string | undefined
12
) {
13
	const url = new URL(`https://api.webflow.com/v2/pages/${page_id}/dom`)
14

15
	for (const [k, v] of [
16
		['locale', locale],
17
		['limit', limit],
18
		['offset', offset]
19
	]) {
20
		if (v !== undefined && v !== '' && k !== undefined) {
21
			url.searchParams.append(k, v)
22
		}
23
	}
24

25
	const response = await fetch(url, {
26
		method: 'GET',
27
		headers: {
28
			Authorization: 'Bearer ' + auth.token
29
		},
30
		body: undefined
31
	})
32

33
	if (!response.ok) {
34
		const text = await response.text()
35
		throw new Error(`${response.status} ${text}`)
36
	}
37

38
	return await response.json()
39
}
40