Edits history of script submission #10100 for ' Allows you to delete a task (xero)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Xero = {
    	token: string
    }
    /**
     * Allows you to delete a task
     * Allows you to delete a specific task
     */
    export async function main(auth: Xero, projectId: string, taskId: string, Xero_Tenant_Id: string) {
    	const url = new URL(`https://api.xero.com/projects.xro/2.0/Projects/${projectId}/Tasks/${taskId}`)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Accept: 'application/json',
    			'Xero-Tenant-Id': Xero_Tenant_Id,
    			Authorization: 'Bearer ' + auth.token
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 515 days ago