mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 05:17:28 -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 {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import {
|
||||
IAuthenticate,
|
||||
IBinaryData,
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeApiError,
|
||||
|
@ -16,6 +12,7 @@ import {
|
|||
} from 'n8n-workflow';
|
||||
|
||||
import { OptionsWithUri } from 'request';
|
||||
import { replaceNullValues } from './GenericFunctions';
|
||||
|
||||
interface OptionData {
|
||||
name: string;
|
||||
|
@ -919,8 +916,7 @@ export class HttpRequest implements INodeType {
|
|||
displayName: 'Query Paramters',
|
||||
},
|
||||
};
|
||||
|
||||
const returnItems: INodeExecutionData[] = [];
|
||||
let returnItems: INodeExecutionData[] = [];
|
||||
const requestPromises = [];
|
||||
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
||||
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
|
||||
// data references which do not get changed still stay behind
|
||||
// but the incoming data does not get changed.
|
||||
// @ts-ignore
|
||||
Object.assign(newItem.binary, items[itemIndex].binary);
|
||||
}
|
||||
|
||||
|
@ -1367,6 +1364,8 @@ export class HttpRequest implements INodeType {
|
|||
}
|
||||
}
|
||||
|
||||
returnItems = returnItems.map(replaceNullValues);
|
||||
|
||||
return this.prepareOutputData(returnItems);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue