//native
type Botify = {
token: string
}
/**
* Get collection detail
* Get the detail of a collection
*/
export async function main(
auth: Botify,
username: string,
project_slug: string,
collection: string,
sequenced: string | undefined
) {
const url = new URL(
`https://api.botify.com/projects/${username}/${project_slug}/collections/${collection}`
)
for (const [k, v] of [['sequenced', sequenced]]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
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 51 days ago