//native
type Phrase = {
token: string
baseUrl: string
}
/**
* Delete a reply
* Delete an existing reply.
*/
export async function main(
auth: Phrase,
project_id: string,
key_id: string,
comment_id: string,
id: string,
branch: string | undefined
) {
const url = new URL(
`${auth.baseUrl}/projects/${project_id}/keys/${key_id}/comments/${comment_id}/replies/${id}`
)
for (const [k, v] of [['branch', branch]]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'DELETE',
headers: {
Authorization: 'ApiToken ' + 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 235 days ago