mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(Metabase Node): Fix issue with question results not correctly being returned (#5665)
This commit is contained in:
parent
8fe34f543e
commit
d1e3c192ba
|
@ -1,10 +1,4 @@
|
||||||
import type {
|
import type { IDataObject, INodeProperties } from 'n8n-workflow';
|
||||||
IDataObject,
|
|
||||||
IExecuteSingleFunctions,
|
|
||||||
IN8nHttpFullResponse,
|
|
||||||
INodeExecutionData,
|
|
||||||
INodeProperties,
|
|
||||||
} from 'n8n-workflow';
|
|
||||||
import { jsonParse } from 'n8n-workflow';
|
import { jsonParse } from 'n8n-workflow';
|
||||||
|
|
||||||
export const questionsOperations: INodeProperties[] = [
|
export const questionsOperations: INodeProperties[] = [
|
||||||
|
@ -56,43 +50,38 @@ export const questionsOperations: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
postReceive: [
|
postReceive: [
|
||||||
// @ts-ignore
|
async function (this, items, responseData) {
|
||||||
async function (
|
const datatype = this.getNodeParameter('format') as string;
|
||||||
this: IExecuteSingleFunctions,
|
|
||||||
_items: INodeExecutionData[],
|
|
||||||
response: IN8nHttpFullResponse,
|
|
||||||
): Promise<INodeExecutionData[]> {
|
|
||||||
const items = _items;
|
|
||||||
const result: INodeExecutionData[] = [];
|
|
||||||
for (let i = 0; i < items.length; i++) {
|
|
||||||
const newItem: INodeExecutionData = {
|
|
||||||
json: items[i].json,
|
|
||||||
binary: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (items[i].binary !== undefined && newItem.binary) {
|
if (datatype !== 'json') {
|
||||||
Object.assign(newItem.binary, items[i].binary);
|
const binaryData = await this.helpers.prepareBinaryData(
|
||||||
}
|
responseData.body as Buffer,
|
||||||
items[i] = newItem;
|
|
||||||
if (this.getNode().parameters.format === 'json') {
|
|
||||||
items[i].json = jsonParse<IDataObject[]>(items[i].json as unknown as string)[0];
|
|
||||||
console.log(items[i].json);
|
|
||||||
delete items[i].binary;
|
|
||||||
} else {
|
|
||||||
items[i].binary!.data = await this.helpers.prepareBinaryData(
|
|
||||||
response.body as Buffer,
|
|
||||||
'data',
|
'data',
|
||||||
response.headers['content-type'] as string,
|
responseData.headers['content-type'] as string,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Transform items
|
||||||
|
items = items.map((item) => {
|
||||||
|
item.json = {};
|
||||||
|
item.binary = { ['data']: binaryData };
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const results = jsonParse<IDataObject[]>(responseData.body as unknown as string);
|
||||||
|
items = results.map((result) => {
|
||||||
|
return {
|
||||||
|
json: {
|
||||||
|
...result,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
result.push(items[i]);
|
return items;
|
||||||
}
|
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
action: 'Result Data a questions',
|
action: 'Get the results from a question',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
default: 'getAll',
|
default: 'getAll',
|
||||||
|
|
Loading…
Reference in a new issue