-
-
Save ifreddyrondon/0c7b75ff201443fa0e35e32e22a4e5eb to your computer and use it in GitHub Desktop.
Google Forms + Webhook : JSON example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onFormSubmit(e) { | |
| var data = { | |
| "form": { | |
| "id": e.source.getId(), | |
| "title": e.source.getTitle() ? e.source.getTitle() : "Untitled Form", | |
| "is_private": e.source.requiresLogin(), | |
| "is_published": e.source.isAcceptingResponses(), | |
| }, | |
| "response": { | |
| "id": e.response.getId(), | |
| "timestamp": e.response.getTimestamp(), | |
| "payload": e.response.getItemResponses().map(function(y) { | |
| return { | |
| h: y.getItem().getTitle(), | |
| k: y.getResponse() | |
| } | |
| }, this).reduce(function(r, y) { | |
| r[y.h] = y.k; | |
| return r | |
| }, {}); | |
| }, | |
| }; | |
| var options = { | |
| method: "post", | |
| payload: JSON.stringify(data, null, 2), | |
| contentType: "application/json; charset=utf-8", | |
| }; | |
| UrlFetchApp.fetch("http://n07-dynamic.lifeho.me:3000", options); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment