Automatically parse response in GraphQL node to JSON

This commit is contained in:
Jan Oberhauser 2019-12-19 16:15:19 -06:00
parent 8acc3c5931
commit 108ffb0d86

View file

@ -221,10 +221,14 @@ export class GraphQL implements INodeType {
});
} else {
if (typeof response === 'string') {
throw new Error('Response body is not valid JSON. Change "Response Format" to "String"');
try {
returnItems.push({ json: JSON.parse(response) });
} catch (e) {
throw new Error('Response body is not valid JSON. Change "Response Format" to "String"');
}
} else {
returnItems.push({ json: response });
}
returnItems.push({ json: response });
}
}