Edits history of script submission #14202 for ' Gets table rows for a given employee and table combination (bamboo_hr)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Gets table rows for a given employee and table combination
     * Returns a data structure representing all the table rows for a given employee and table combination. The result is not sorted in any particular order.
     */
    export async function main(auth: RT.BambooHr, id: string, table: string) {
    	const url = new URL(
    		`https://${auth.companyDomain}.bamboohr.com/api/v1/employees/${id}/tables/${table}`
    	)
    
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
    		},
    		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