type Convertkit = {
apiSecret: string
}
export async function main(resource: Convertkit, email: string) {
const endpoint = `https://api.convertkit.com/v3/unsubscribe`
const body = {
api_secret: resource.apiSecret,
email
}
const response = await fetch(endpoint, {
method: 'PUT',
headers: {
'Content-Type': 'application/json; charset=utf-8'
},
body: JSON.stringify(body)
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
return data.subscriber
}
Submitted by hugo697 79 days ago