0

Delete a Subscriber

by
Published Aug 26, 2024
Script mailerlite Verified

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 652 days ago
1
type MailerLite = {
2
	apiToken: string
3
}
4

5
export async function main(resource: MailerLite, subscriberId: string) {
6
	const endpoint = `https://connect.mailerlite.com/api/subscribers/${subscriberId}`
7

8
	const response = await fetch(endpoint, {
9
		method: 'DELETE',
10
		headers: {
11
			'Content-Type': 'application/json',
12
			Accept: 'application/json',
13
			Authorization: `Bearer ${resource.apiToken}`
14
		}
15
	})
16

17
	if (!response.ok) {
18
		throw new Error(`HTTP error! status: ${response.status}`)
19
	}
20

21
	return { success: true }
22
}
23