Edits history of script submission #8934 for ' Remove Subscriber from a Group (mailerlite)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type MailerLite = {
    	apiToken: string
    }
    
    export async function main(resource: MailerLite, groupId: string, subscriberId: string) {
    	const endpoint = `https://connect.mailerlite.com/api/subscribers/${subscriberId}/groups/${groupId}`
    
    	const response = await fetch(endpoint, {
    		method: 'DELETE',
    		headers: {
    			'Content-Type': 'application/json',
    			Accept: 'application/json',
    			Authorization: `Bearer ${resource.apiToken}`
    		}
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	return { success: true }
    }
    

    Submitted by hugo697 652 days ago