mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(HTTP Request Node): Fix issue with requests that return null (#3498)
* ⚡ fix * ⚡ Remove null values at node level * 🔥 Remove unused imports * ⚡ Small change Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
parent
57d466850a
commit
7346da0b34
|
@ -0,0 +1,8 @@
|
||||||
|
import { INodeExecutionData } from "n8n-workflow";
|
||||||
|
|
||||||
|
export const replaceNullValues = (item: INodeExecutionData) => {
|
||||||
|
if (item.json === null) {
|
||||||
|
item.json = {};
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
};
|
|
@ -1,14 +1,10 @@
|
||||||
import path from 'path';
|
|
||||||
import {
|
import {
|
||||||
IExecuteFunctions,
|
IExecuteFunctions,
|
||||||
} from 'n8n-core';
|
} from 'n8n-core';
|
||||||
import {
|
import {
|
||||||
IAuthenticate,
|
|
||||||
IBinaryData,
|
IBinaryData,
|
||||||
IDataObject,
|
IDataObject,
|
||||||
ILoadOptionsFunctions,
|
|
||||||
INodeExecutionData,
|
INodeExecutionData,
|
||||||
INodePropertyOptions,
|
|
||||||
INodeType,
|
INodeType,
|
||||||
INodeTypeDescription,
|
INodeTypeDescription,
|
||||||
NodeApiError,
|
NodeApiError,
|
||||||
|
@ -16,6 +12,7 @@ import {
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import { OptionsWithUri } from 'request';
|
import { OptionsWithUri } from 'request';
|
||||||
|
import { replaceNullValues } from './GenericFunctions';
|
||||||
|
|
||||||
interface OptionData {
|
interface OptionData {
|
||||||
name: string;
|
name: string;
|
||||||
|
@ -919,8 +916,7 @@ export class HttpRequest implements INodeType {
|
||||||
displayName: 'Query Paramters',
|
displayName: 'Query Paramters',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
let returnItems: INodeExecutionData[] = [];
|
||||||
const returnItems: INodeExecutionData[] = [];
|
|
||||||
const requestPromises = [];
|
const requestPromises = [];
|
||||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||||
const requestMethod = this.getNodeParameter('requestMethod', itemIndex) as string;
|
const requestMethod = this.getNodeParameter('requestMethod', itemIndex) as string;
|
||||||
|
@ -1263,6 +1259,7 @@ export class HttpRequest implements INodeType {
|
||||||
// Create a shallow copy of the binary data so that the old
|
// Create a shallow copy of the binary data so that the old
|
||||||
// data references which do not get changed still stay behind
|
// data references which do not get changed still stay behind
|
||||||
// but the incoming data does not get changed.
|
// but the incoming data does not get changed.
|
||||||
|
// @ts-ignore
|
||||||
Object.assign(newItem.binary, items[itemIndex].binary);
|
Object.assign(newItem.binary, items[itemIndex].binary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1367,6 +1364,8 @@ export class HttpRequest implements INodeType {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
returnItems = returnItems.map(replaceNullValues);
|
||||||
|
|
||||||
return this.prepareOutputData(returnItems);
|
return this.prepareOutputData(returnItems);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue