26 lines
680 B
TypeScript
26 lines
680 B
TypeScript
import { getBitrixMethodUrl } from '../../core/config';
|
|
import { fetchBalancer } from '../../core/bitrix/client';
|
|
|
|
export function getTemplate(templateID: number) {
|
|
const result = fetchBalancer(
|
|
getBitrixMethodUrl('templates', 'tasks.template.get'),
|
|
{
|
|
includePublicKey: true,
|
|
muteHttpExceptions: true,
|
|
payloadHeaders: { 'Content-Type': 'application/json' },
|
|
body: { templateId: templateID },
|
|
}
|
|
);
|
|
|
|
if (result.code !== 200) {
|
|
throw new Error(JSON.stringify(result.data));
|
|
}
|
|
|
|
const body = (result.data || {}).body;
|
|
if (result.data.error || !body || !body.result || !body.result.ID) {
|
|
return null;
|
|
}
|
|
|
|
return body.result;
|
|
}
|