My first post on here so forgive if I’ve missed anything salient out.
I have a Gatsby site bootstrapped from a started for a friend studying for a PhD: GitHub - SeanAlexanderHarris/example-company-website-gatsby-sanity-combo: This is an example company website using Gatsby and Sanity in combination. / https://6011d6993c0621000798e870--bealth.netlify.app
I am trying to add a contact form that will use SendGrid to send an email to him.
I have a Netlify function in a functions folder called ‘contactBealth’.
I also have a simple hello world test function in another folder called ‘hello’.
This work has been done on a branch & as such is triggering a preview deploy.
There are a few issues I think are related:
- although the build logs for the preview deploy acknowledge the functions, none are actually deployed (they do not appear in the Netlify functions dashboard ui)
- both functions are invokable with the Netlify cli
netlify functions:invoke contactBealth&
netlify functions:invoke hello& return a response.
- both functions return a response when running locally and appear to build as I can console log throughout the function
- when visiting the function url (http://localhost:8888/.netlify/functions/contactBealth), the hello function returns a response but the contactBealth function result in the following locally:
SyntaxError: Unexpected token u in JSON at position 0 JSON.parse (<anonymous>) Object.exports.handler (/Users/seanharris/Code/bealthcorp/web/functions/contactBealth/contactBealth.js:13:21) Object._executeSync (/Users/seanharris/.nvm/versions/node/v14.15.0/lib/node_modules/netlify-cli/node_modules/lambda-local/build/lambdalocal.js:286:47) Object.execute (/Users/seanharris/.nvm/versions/node/v14.15.0/lib/node_modules/netlify-cli/node_modules/lambda-local/build/lambdalocal.js:83:22) executeSynchronousFunction (/Users/seanharris/.nvm/versions/node/v14.15.0/lib/node_modules/netlify-cli/src/utils/serve-functions.js:102:15) handler (/Users/seanharris/.nvm/versions/node/v14.15.0/lib/node_modules/netlify-cli/src/utils/serve-functions.js:248:12) Layer.handle [as handle_request] (/Users/seanharris/.nvm/versions/node/v14.15.0/lib/node_modules/netlify-cli/node_modules/express/lib/router/layer.js:95:5) next (/Users/seanharris/.nvm/versions/node/v14.15.0/lib/node_modules/netlify-cli/node_modules/express/lib/router/route.js:137:13) next (/Users/seanharris/.nvm/versions/node/v14.15.0/lib/node_modules/netlify-cli/node_modules/express/lib/router/route.js:131:14) next (/Users/seanharris/.nvm/versions/node/v14.15.0/lib/node_modules/netlify-cli/node_modules/express/lib/router/route.js:131:14)
My toml file is:
[build] base = "web/" publish = "public" functions = "functions" command = "npm run build"