//native
type Beamer = {
apiKey: string
}
export async function main(
resource: Beamer,
postId: string,
commentData: {
text?: string
userId?: string
userEmail?: string
userFirstname?: string
userLastname?: string
}
) {
const endpoint = `https://api.getbeamer.com/v0/posts/${postId}/comments`
const response = await fetch(endpoint, {
method: 'POST',
headers: {
Accept: 'application/json',
'Beamer-Api-Key': resource.apiKey,
'Content-Type': 'application/json'
},
body: JSON.stringify(commentData)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
const data = await response.json()
return data
}
Submitted by hugo697 2 days ago