Hey! I’m trying to use a function that sends down a PDF to authenticated users.
I’m having problems reading the static PDF file when my function is deployed. I even found this example: function-deploy-test/zipped-function.js at master · netlify/function-deploy-test · GitHub
I copied this example line for line (and file for file) and this guy function-deploy-test/zipped-function.js at master · netlify/function-deploy-test · GitHub
still prints “undefined” in the logs.
I’m not sure what’s missing in that example, but you may be able to try something like this:
The deployed function that sends down a pdf is here: https://examples.netlify.horse/.netlify/functions/send-down-pdf
The main difference is that your netlify.toml would probably be less complicated If you want your function to have its own dependencies aside from the root package.json, you’d do something like this:
functions = "func"
command = "cd func/send-down-pdf/ && npm install"
Let us know if that helps or if you have other questions.
Thank you, my use case was a mailer function with a transactional html email template for a gatsby site which worked in dev but not after deploy. I spent 3 days on this issue because I could not find any clear documentation on how to load files with functions for a gatsby site. First I used netlify-lambda which led me nowhere, finally today I switched to netlify-cli and implemented your solution and it worked! I am sharing here my netlify.toml for reference.
publish = "public"
functions = "functions"
command = "gatsby build && cd functions/mailer/ && npm install"
command = "gatsby develop"
thanks a bunch for sharing, and glad it is working now for you!