Edits history of script submission #20863 for ' Delete a function (supabase)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Supabase = {
    	key: string
    }
    /**
     * Delete a function
     * Deletes a function with the specified slug from the specified project.
     */
    export async function main(auth: Supabase, ref: string, function_slug: string) {
    	const url = new URL(`https://api.supabase.com/v1/projects/${ref}/functions/${function_slug}`)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: 'Bearer ' + auth.key
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 207 days ago