//native
type TheirStack = {
apiKey: string
}
/**
* Get Technology Categories
* This endpoint lets you get all the categories of the technologies we monitor, and the number of technologies and companies in each category.
*/
export async function main(
auth: TheirStack,
category_slug: string | undefined,
num_technologies_per_category: string | undefined
) {
const url = new URL(`https://api.theirstack.com/v0/catalog/technologies/categories`)
for (const [k, v] of [
['category_slug', category_slug],
['num_technologies_per_category', num_technologies_per_category]
]) {
if (v !== undefined && v !== '' && k !== undefined) {
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