fix(HTTP Request Node): Ignore empty body for auto detect json (#5215)

This commit is contained in:
feelgood-interface 2023-02-16 12:00:06 +01:00 committed by GitHub
parent 7954ed3cfb
commit af703371fc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1344,7 +1344,17 @@ export class HttpRequestV3 implements INodeType {
const responseContentType = response.headers['content-type'] ?? '';
if (responseContentType.includes('application/json')) {
responseFormat = 'json';
response.body = jsonParse(Buffer.from(response.body).toString());
const neverError = this.getNodeParameter(
'options.response.response.neverError',
0,
false,
) as boolean;
const data = Buffer.from(response.body).toString();
response.body = jsonParse(data, {
...(neverError
? { fallbackValue: {} }
: { errorMessage: 'Invalid JSON in response body' }),
});
} else if (binaryContentTypes.some((e) => responseContentType.includes(e))) {
responseFormat = 'file';
} else {