mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
fix(HTTP Request Node): Ignore empty body for auto detect json (#5215)
This commit is contained in:
parent
7954ed3cfb
commit
af703371fc
|
@ -1344,7 +1344,17 @@ export class HttpRequestV3 implements INodeType {
|
||||||
const responseContentType = response.headers['content-type'] ?? '';
|
const responseContentType = response.headers['content-type'] ?? '';
|
||||||
if (responseContentType.includes('application/json')) {
|
if (responseContentType.includes('application/json')) {
|
||||||
responseFormat = '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))) {
|
} else if (binaryContentTypes.some((e) => responseContentType.includes(e))) {
|
||||||
responseFormat = 'file';
|
responseFormat = 'file';
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue