{"size": 725, "ext": "js", "max_stars_repo_path": "formio-get.js", "max_stars_repo_name": "formio/formio-red", "max_stars_repo_stars_event_min_datetime": "2016-11-18T17:56:41.000Z", "max_stars_repo_stars_event_max_datetime": "2021-04-18T20:32:27.000Z", "max_issues_repo_path": "formio-get.js", "max_issues_repo_name": "formio/formio-red", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "formio-get.js", "max_forks_repo_name": "formio/formio-red", "max_forks_repo_forks_event_min_datetime": "2017-03-30T02:16:08.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-27T12:03:26.000Z"}
{"max_stars_count": 8, "max_issues_count": null, "max_forks_count": 5, "avg_line_length": 26.8518518519, "max_line_length": 73, "alphanum_fraction": 0.5903448276}
module.exports = function(RED) {
  "use strict";
  /**
   * Save a form.
   * @param node
   * @constructor
   */
  function FormioGet(node) {
    RED.nodes.createNode(this, node);
    var config = RED.nodes.getNode(node.formio);
    this.on("input", function(msg) {
      var src = config.project + '/' + node.form;
      var formio = require('formio-service')({
        formio: config.project,
        key: config.apikey
      });

      var query = msg.query || {};
      (new formio.Form(src)).loadSubmissions(query).then(function(subs) {
        msg.submissions = subs;
        this.send(msg);
      }.bind(this)).catch(this.error.bind(this));
    }.bind(this));
  }
  RED.nodes.registerType('formio get', FormioGet);
}
