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
1 changed files with 2 additions and 2 deletions

View File

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