Edits history of script submission #9435 for ' Get filter (botify)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Botify = {
    	token: string
    }
    /**
     * Get filter
     * Retrieve a specific project saved, account or recommended filter's name, ID and filter value
     */
    export async function main(
    	auth: Botify,
    	username: string,
    	project_slug: string,
    	identifier: string
    ) {
    	const url = new URL(
    		`https://api.botify.com/projects/${username}/${project_slug}/filters/${identifier}`
    	)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		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