Edits history of script submission #9411 for ' Create job (botify)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Botify = {
    	token: string
    }
    /**
     * Create job
     * Creates a job instance of a class which depends on the "job_type" parameter you sent. Returns the model id that manages the task.
     */
    export async function main(auth: Botify) {
    	const url = new URL(`https://api.botify.com/jobs`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			Authorization: 'Token ' + 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 566 days ago