//native
type TheirStack = {
apiKey: string
}
/**
* Get Industries
* This endpoint lets you:
- List all the industries and their codes
- See how many jobs and companies we have per industry
- Search for an industry
Calls to this endpoint don't cost you credits.
*/
export async function main(
auth: TheirStack,
industry: string | undefined,
page: string | undefined,
limit: string | undefined
) {
const url = new URL(`https://api.theirstack.com/v0/catalog/industries`)
for (const [k, v] of [
['industry', industry],
['page', page],
['limit', limit]
]) {
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