Edits history of script submission #18544 for ' Delete a recipe (readme)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Delete a recipe
     * Delete a recipe from your ReadMe project.
    
    >📘
    > This route is only available to projects that are using [ReadMe Refactored](https://docs.readme.com/main/docs/welcome-to-readme-refactored).
     */
    export async function main(auth: RT.Readme, branch: string, slug: string) {
    	const url = new URL(`https://api.readme.com/v2/branches/${branch}/recipes/${slug}`)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 235 days ago