Open kaushalmodi opened 6 years ago
I am a JS coder, and I can 100% plus one this as well. Going from the main doc (https://www.netlify.com/docs/functions/), it is not clear when you can just "drop a file" in (which is how it starts you off) and when you need a build process of some sort.
Because of this - I'm still stuck trying to get npm stuff working, async, etc.
Hello,
I am not a JS coder, and so am not used to tooling like yarn, Babel, etc.
I spent an embarrassing amount of time to figure out why
import querystring from "querystring";
in https://github.com/netlify/netlify-functions-example/blob/master/src/lambda/hello_name_post.js didn't work "out of box".Unbeknownst to me, the
import
keyword is not supported by default unless you use Babel or something (which I believe you are doing in your yarn magic). Thanks to https://stackoverflow.com/questions/39436322/node-js-syntaxerror-unexpected-token-import to help me figure that out.You could have simply used
const querystring = require("querystring");
instead ofimport querystring from "querystring";
.Here is my attempt at a super-simplified versions of your examples where focus is on the JS code (generated using Nim) than on yarn/Babel/etc: https://nim-lambda-functions.netlify.com/
The example under "Hello, {name} (POST version)" works the same way as in your version.
Please make all the examples easier to adopt as everyone might not be using yarn, Babel, etc.