modified: backend/src/services/AqlExecutor.ts
This commit is contained in:
@@ -132,6 +132,14 @@ export class AqlExecutor {
|
|||||||
Object.assign(headers, customHeaders);
|
Object.assign(headers, customHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Логируем запрос
|
||||||
|
console.log('\n=== AQL Request ===');
|
||||||
|
console.log('URL:', fullUrl);
|
||||||
|
console.log('Method:', config.method);
|
||||||
|
console.log('Headers:', JSON.stringify(headers, null, 2));
|
||||||
|
console.log('Body:', processedBody || '(no body)');
|
||||||
|
console.log('===================\n');
|
||||||
|
|
||||||
// Выполняем HTTP запрос
|
// Выполняем HTTP запрос
|
||||||
const response = await fetch(fullUrl, {
|
const response = await fetch(fullUrl, {
|
||||||
method: config.method,
|
method: config.method,
|
||||||
@@ -144,11 +152,27 @@ export class AqlExecutor {
|
|||||||
// Проверяем статус ответа
|
// Проверяем статус ответа
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorText = await response.text();
|
const errorText = await response.text();
|
||||||
|
console.log('\n=== AQL Error Response ===');
|
||||||
|
console.log('Status:', response.status);
|
||||||
|
console.log('Response:', errorText);
|
||||||
|
console.log('==========================\n');
|
||||||
throw new Error(`AQL API error (${response.status}): ${errorText}`);
|
throw new Error(`AQL API error (${response.status}): ${errorText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Парсим JSON ответ
|
// Парсим JSON ответ
|
||||||
const data = await response.json();
|
const responseText = await response.text();
|
||||||
|
console.log('\n=== AQL Response ===');
|
||||||
|
console.log('Status:', response.status);
|
||||||
|
console.log('Raw Response:', responseText);
|
||||||
|
console.log('====================\n');
|
||||||
|
|
||||||
|
let data;
|
||||||
|
try {
|
||||||
|
data = JSON.parse(responseText);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to parse JSON response:', e);
|
||||||
|
throw new Error(`Invalid JSON response: ${responseText.substring(0, 200)}`);
|
||||||
|
}
|
||||||
|
|
||||||
// Нормализуем ответ к формату QueryResult
|
// Нормализуем ответ к формату QueryResult
|
||||||
let rows: any[];
|
let rows: any[];
|
||||||
|
|||||||
Reference in New Issue
Block a user