n8n int cleaning
This commit is contained in:
parent
241fa4455c
commit
698a6e52ee
@ -29,7 +29,8 @@ export class N8nService {
|
||||
|
||||
const response = await axios.post(this.webhookUrl, missionData, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
timeout: 30000 // 30 second timeout
|
||||
});
|
||||
@ -38,17 +39,37 @@ export class N8nService {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
headers: response.headers,
|
||||
data: response.data
|
||||
data: response.data,
|
||||
contentType: response.headers['content-type']
|
||||
});
|
||||
|
||||
// Handle string response
|
||||
if (typeof response.data === 'string') {
|
||||
console.log('Received string response from n8n, treating as success');
|
||||
console.warn('Received string response from n8n instead of JSON:', {
|
||||
response: response.data,
|
||||
contentType: response.headers['content-type'],
|
||||
webhookUrl: this.webhookUrl
|
||||
});
|
||||
|
||||
// Try to parse the string as JSON if it looks like JSON
|
||||
if (response.data.trim().startsWith('{') || response.data.trim().startsWith('[')) {
|
||||
try {
|
||||
const parsedData = JSON.parse(response.data);
|
||||
console.log('Successfully parsed string response as JSON:', parsedData);
|
||||
return {
|
||||
success: true,
|
||||
results: parsedData
|
||||
};
|
||||
} catch (parseError) {
|
||||
console.error('Failed to parse string response as JSON:', parseError);
|
||||
}
|
||||
}
|
||||
|
||||
// If we can't parse it as JSON, return default structure
|
||||
return {
|
||||
success: true,
|
||||
results: {
|
||||
message: response.data,
|
||||
// Add default empty integration results
|
||||
leantimeProjectId: null,
|
||||
outlineCollectionId: null,
|
||||
rocketChatChannelId: null,
|
||||
@ -73,6 +94,7 @@ export class N8nService {
|
||||
// Ensure the response has the expected structure
|
||||
const result = response.data;
|
||||
if (!result.results) {
|
||||
console.warn('Response missing results object, adding default structure');
|
||||
result.results = {
|
||||
leantimeProjectId: null,
|
||||
outlineCollectionId: null,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user