Edits history of script submission #9108 for ' Create List Entry (zixflow)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    // native
    
    type Zixflow = {
    	apiKey: string
    }
    
    export async function main(
    	resource: Zixflow,
    	listId: string,
    	body: {
    		recordId: string
    		data?: Record<string, any>
    	}
    ) {
    	const endpoint = `https://api.zixflow.com/api/v1/list-entries/${listId}`
    
    	const response = await fetch(endpoint, {
    		method: 'POST',
    		headers: {
    			Authorization: `Bearer ${resource.apiKey}`,
    			'Content-Type': 'application/json'
    		},
    		body: JSON.stringify(body)
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	const data = await response.json()
    
    	return data
    }
    

    Submitted by hugo697 606 days ago