1
1
mirror of https://github.com/n8n-io/n8n.git synced 2024-10-07 10:07:19 +03: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:
Michael Kret 2022-06-13 23:25:09 +03:00 committed by GitHub
parent 57d466850a
commit 7346da0b34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View File

@ -0,0 +1,8 @@
import { INodeExecutionData } from "n8n-workflow";
export const replaceNullValues = (item: INodeExecutionData) => {
if (item.json === null) {
item.json = {};
}
return item;
};

View File

@ -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);
}
}