added filter feature
This commit is contained in:
parent
f1de06d486
commit
3e318f4b78
2 changed files with 19 additions and 3 deletions
|
|
@ -7,12 +7,14 @@ module.exports = function(RED) {
|
|||
this.document = RED.nodes.getNode(config.document);
|
||||
this.server = RED.nodes.getNode(config.server);
|
||||
this.table = config.tableId
|
||||
this.filter = config.filter
|
||||
|
||||
node.on('input', async function(msg, send, done) {
|
||||
const protocol=this.server.tlsEnabled === true ? "https" : "http";
|
||||
const url=protocol+"://"+this.server.hostname+":"+this.server.port;
|
||||
|
||||
const filter=this.filter && this.filter !== "" ? JSON.parse(this.filter) : undefined
|
||||
const api = new GristDocAPI(this.document.docid,{apiKey:this.server.apiKey,server:url});
|
||||
api.fetchTable(this.table).then(data => {
|
||||
api.fetchTable(this.table,filter).then(data => {
|
||||
node.send({payload:data,topic:this.table})
|
||||
}).catch(reason => done(reason,"Failed to perform grist request to "+url));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue