Tolerate missing json key in function node output (#2885)

* 🔨 implemented Tolerate missing json key in function node output

* 🔨 clean up

* Small change to code

*  tolerate returning object

*  Rename function

Co-authored-by: Omar Ajoue <krynble@gmail.com>
Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
Michael Kret
2022-03-07 10:54:52 +02:00
committed by GitHub
parent af09bf8e6a
commit 62e05cf0b3
3 changed files with 49 additions and 0 deletions

View File

@@ -119,6 +119,8 @@ return items;`,
try {
// Execute the function code
items = (await vm.run(`module.exports = async function() {${functionCode}\n}()`, __dirname));
items = this.helpers.normalizeItems(items);
// Do very basic validation of the data
if (items === undefined) {
throw new NodeOperationError(this.getNode(), 'No data got returned. Always return an Array of items!');