Edits history of script submission #15575 for ' Retrieve List of Managers (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Retrieve List of Managers
     * Retrieve a list of all managers in the organization along with pagination details.
     **Token scopes**: `organizations:read`
     */
    export async function main(auth: RT.Deel, limit?: string | undefined, offset?: string | undefined) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/managers`)
    	for (const [k, v] of [
    		['limit', limit],
    		['offset', offset]
    	]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago