//native
type Beamer = {
apiKey: string
}
export async function main(
resource: Beamer,
body: {
title: string[]
content: string[]
category: string
publish?: boolean
archive?: boolean
pinned?: boolean
showInWidget?: boolean
showInStandalone?: boolean
enableFeedback?: boolean
enableReactions?: boolean
enableSocialShare?: boolean
autoOpen?: boolean
sendPushNotification?: boolean
userEmail?: string
fixedBoostedAnnouncement?: boolean
}
) {
const url = new URL(`https://api.getbeamer.com/v0/posts`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Beamer-Api-Key': resource.apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`HTTP error! status: ${response.status} - ${text}`)
}
const data = await response.json()
return data
}
Submitted by hugo697 2 days ago