n8n int cleaning
This commit is contained in:
parent
12f673678d
commit
6d2e0fe04b
@ -30,12 +30,24 @@ export class N8nService {
|
|||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
console.log('Received response from n8n:', JSON.stringify(result, null, 2));
|
console.log('Received response from n8n:', JSON.stringify(result, null, 2));
|
||||||
|
|
||||||
// Handle different response formats
|
// Handle lastNodeJson format
|
||||||
if (typeof result === 'string') {
|
if (result.lastNodeJson) {
|
||||||
console.warn('Received string response from n8n:', result);
|
try {
|
||||||
|
const parsedResults = JSON.parse(result.lastNodeJson);
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
results: {
|
||||||
|
leantimeProjectId: parsedResults.leantimeProjectId?.toString() || null,
|
||||||
|
outlineCollectionId: parsedResults.outlineCollectionId?.toString() || null,
|
||||||
|
rocketChatChannelId: parsedResults.rocketChatChannelId?.toString() || null,
|
||||||
|
giteaRepositoryUrl: parsedResults.giteaRepositoryUrl || null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} catch (parseError) {
|
||||||
|
console.error('Error parsing lastNodeJson:', parseError);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
error: 'Invalid response format from n8n',
|
error: 'Failed to parse n8n response',
|
||||||
results: {
|
results: {
|
||||||
leantimeProjectId: null,
|
leantimeProjectId: null,
|
||||||
outlineCollectionId: null,
|
outlineCollectionId: null,
|
||||||
@ -44,8 +56,9 @@ export class N8nService {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Extract results from the response
|
// Handle regular JSON response
|
||||||
const integrationResults = result.results || result;
|
const integrationResults = result.results || result;
|
||||||
console.log('Integration results:', JSON.stringify(integrationResults, null, 2));
|
console.log('Integration results:', JSON.stringify(integrationResults, null, 2));
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user