type Baremetrics = {
apiKey: string
}
export async function main(
resource: Baremetrics,
params?: {
page?: number
per_page?: number
}
) {
const queryParams = new URLSearchParams()
if (params?.page) {
queryParams.append('page', params.page.toString())
}
if (params?.per_page) {
queryParams.append('per_page', params.per_page.toString())
}
const endpoint = `https://api.baremetrics.com/v1/sources?${queryParams.toString()}`
const response = await fetch(endpoint, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
Accept: 'application/json',
Authorization: `Bearer ${resource.apiKey}`
}
})
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`)
}
const data = await response.json()
return data
}
Submitted by hugo697 87 days ago