by hugo697 ยท 10/11/2024
1
type Acumbamail = {
2
authToken: string
3
}
4
5
export async function main(
6
resource: Acumbamail,
7
origin_template_id: number,
8
template_name: string
9
) {
10
const endpoint = 'https://acumbamail.com/api/1/duplicateTemplate/'
11
12
const formData = new FormData()
13
formData.append('auth_token', resource.authToken)
14
formData.append('origin_template_id', origin_template_id.toString())
15
formData.append('template_name', template_name)
16
17
const response = await fetch(endpoint, {
18
method: 'POST',
19
headers: {
20
'Cache-Control': 'no-cache'
21
},
22
body: formData
23
})
24
25
if (!response.ok) {
26
throw new Error(`HTTP error! status: ${response.status}`)
27
28
29
const data = await response.json()
30
31
return data
32
33