//native
type Botify = {
token: string
}
/**
* Get url detail
* Gets the detail of an URL for an analysis
*/
export async function main(
auth: Botify,
username: string,
project_slug: string,
analysis_slug: string,
url: string,
fields: string | undefined
) {
const endpoint = new URL(
`https://api.botify.com/analyses/${username}/${project_slug}/${analysis_slug}/urls/${url}`
)
for (const [k, v] of [['fields', fields]]) {
if (v !== undefined && v !== '' && k !== undefined) {
endpoint.searchParams.append(k, v)
}
}
const response = await fetch(endpoint, {
method: 'GET',
headers: {
Authorization: 'Token ' + auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.text()
}
Submitted by hugo697 2 days ago