//native
/**
* List of all industry subcategories.
* List industry subcategories with their respective categories.
**Token scopes**: `legal-entity:read`
*/
export async function main(
auth: RT.Deel,
limit?: string | undefined,
order?: 'ASC' | 'DESC' | undefined,
sort_by?: 'subcategoryName' | 'categoryName' | undefined,
cursor?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/industries`)
for (const [k, v] of [
['limit', limit],
['order', order],
['sort_by', sort_by],
['cursor', cursor]
]) {
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