//native
type Botify = {
token: string
}
/**
* Get project name by pulse website id
* Get project informations with a website id from pulse
*/
export async function main(
auth: Botify,
pulse_website_id: string,
page: string | undefined,
size: string | undefined
) {
const url = new URL(`https://api.botify.com/pulse_website/${pulse_website_id}`)
for (const [k, v] of [
['page', page],
['size', size]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Token ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 51 days ago