//native
type TheirStack = {
apiKey: string
}
/**
* Get Jobs And Companies Per Job Country Code
* This endpoint will return all the country codes and the number of jobs whose location's country code is the given one, and the number of companies with jobs in that country.
Calls to this endpoint don't cost you credits.
*/
export async function main(
auth: TheirStack,
country: string | undefined,
page: string | undefined,
limit: string | undefined
) {
const url = new URL(`https://api.theirstack.com/v0/catalog/jobs_companies_per_job_country_code`)
for (const [k, v] of [
['country', country],
['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