debug log

This commit is contained in:
Timofey Gelazoniya 2022-10-21 10:23:23 +03:00
parent e63870fac6
commit abb04c5a25
Signed by: zeldon
GPG Key ID: 047886915281DD2A

View File

@ -17,6 +17,8 @@ export class BalabolaError extends Error { }
const BASE_URL = 'https://yandex.ru/lab/api/yalm/text3';
export async function balabola(query: string, intro: number): Promise<string> {
logger.debug({ query, intro });
const result = await fetch(BASE_URL, {
method: 'POST',
body: JSON.stringify({
@ -26,8 +28,6 @@ export async function balabola(query: string, intro: number): Promise<string> {
})
}).then(res => res.json()) as BalabolaResponse;
logger.debug(result);
if (result.bad_query === 1) throw new BalabolaError('bad query');
return result.text;