Edits history of script submission #12984 for ' Get ping (recraft)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Recraft = {
    	apiKey: string
    }
    /**
     * Get ping
     *
     */
    export async function main(auth: Recraft) {
    	const url = new URL(`https://external.api.recraft.ai/ping`)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 428 days ago