Edits history of script submission #8944 for ' Remove Tag From Subscriber By Id (convertkit)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Convertkit = {
    	apiSecret: string
    }
    
    export async function main(resource: Convertkit, subscriberId: string, tagId: string) {
    	const queryParams = new URLSearchParams({
    		api_secret: resource.apiSecret
    	})
    
    	const endpoint = `https://api.convertkit.com/v3/subscribers/${subscriberId}/tags/${tagId}?${queryParams.toString()}`
    
    	const response = await fetch(endpoint, {
    		method: 'DELETE',
    		headers: {
    			'Content-Type': 'application/json'
    		}
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	const data = await response.json()
    
    	return data
    }
    

    Submitted by hugo697 637 days ago