n8n int cleaning
This commit is contained in:
parent
12f673678d
commit
6d2e0fe04b
@ -30,22 +30,35 @@ export class N8nService {
|
||||
const result = await response.json();
|
||||
console.log('Received response from n8n:', JSON.stringify(result, null, 2));
|
||||
|
||||
// Handle different response formats
|
||||
if (typeof result === 'string') {
|
||||
console.warn('Received string response from n8n:', result);
|
||||
return {
|
||||
success: false,
|
||||
error: 'Invalid response format from n8n',
|
||||
results: {
|
||||
leantimeProjectId: null,
|
||||
outlineCollectionId: null,
|
||||
rocketChatChannelId: null,
|
||||
giteaRepositoryUrl: null
|
||||
}
|
||||
};
|
||||
// Handle lastNodeJson format
|
||||
if (result.lastNodeJson) {
|
||||
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 {
|
||||
success: false,
|
||||
error: 'Failed to parse n8n response',
|
||||
results: {
|
||||
leantimeProjectId: null,
|
||||
outlineCollectionId: null,
|
||||
rocketChatChannelId: null,
|
||||
giteaRepositoryUrl: null
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Extract results from the response
|
||||
// Handle regular JSON response
|
||||
const integrationResults = result.results || result;
|
||||
console.log('Integration results:', JSON.stringify(integrationResults, null, 2));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user