Edits history of script submission #8924 for ' Custom Fields: Update Field (convertkit)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Convertkit = {
    	apiSecret: string
    }
    
    export async function main(resource: Convertkit, customFieldId: string, label: string) {
    	const endpoint = `https://api.convertkit.com/v3/custom_fields/${customFieldId}`
    
    	const body = {
    		api_secret: resource.apiSecret,
    		label
    	}
    
    	const response = await fetch(endpoint, {
    		method: 'PUT',
    		headers: {
    			'Content-Type': 'application/json'
    		},
    		body: JSON.stringify(body)
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	return { success: true }
    }
    

    Submitted by hugo697 637 days ago