I got it soived. It has to do with some webpack issues.
I got this solved by changing to const fetch = request('node-fetch').default;
.
My function returns a body to the handler function, which stringify
s it, and wraps it with the appropriate header/status code for proper return so no issue there.
On this subject though, is there any way you could point me to t template/set of files on how to build the most minimal project with a single function, that uses ES6? No matter what I tried (renaming file extensions to .mjs
, adding "type": "module
to package.json
etc.) something got broken. I had to revert all my code back to require
s, and that’s what broke node-fetch
.
Perhaps just suggest to the team building netlify-cli
to add generators: minimal web site, minimal function, minimal React site (can use create-react-app
to generate a site, and then add the Netlify flair).
Thanks for trying to assist!