Skip to content

Commit

Permalink
cleanup two
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieKolb committed Nov 19, 2024
1 parent d440ba0 commit 5dcc571
Showing 1 changed file with 2 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,10 @@ export class ToolWorkflow implements INodeType {
if (executionError) {
void this.addOutputData(NodeConnectionType.AiTool, index, executionError, metadata);
} else {
const parsedResponse = jsonParse<IDataObject>(response);
// Output always needs to be an object
// so we try to parse the response as JSON and if it fails we just return the string wrapped in an object
void this.addOutputData(
NodeConnectionType.AiTool,
index,
[[{ json: typeof parsedResponse === 'object' ? parsedResponse : { response } }]],
metadata,
);
const json = jsonParse<IDataObject>(response, { fallbackValue: { response } });
void this.addOutputData(NodeConnectionType.AiTool, index, [[{ json }]], metadata);
}
return response;
};
Expand Down

0 comments on commit 5dcc571

Please sign in to comment.