The issue with this is I think after the function goes to sleep the cached variable gets deleted, another issue is the first API Call takes a long time to finish. I'm also getting some errors while running this code
(node:19101) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'statusCode' of undefined
at callback (/home/sc/web-projects/ecomm/node_modules/netlify-lambda/lib/serve.js:35:42)
at /home/sc/web-projects/ecomm/node_modules/netlify-lambda/lib/serve.js:68:7
at processTicksAndRejections (internal/process/task_queues.js:93:5)
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
I don't why that is as i have provided try{} catch{} and then .catch methods.
Can someone guide me to a better solution or critique me on how i can better implement what i am trying to achieve. Thank You.
Hi Guys, I am receiving 502 on netlify even though it returns the content string. Anybody experienced this before?
It returns my content in the error header, and returns "Http failure response for https://demos-portal.netlify.com/.netlify/functions/get-demos: 502 OK"
in the message
@jetstreamin what you mean to include the zip in the lambda? You mean to transpile the files and move the files? Maybe i'm not clear, sorry.
The warning says that I could have my functions in nested folders which is true in my case. But i do not know what to do. Maybe is a thing with netlify-lambda or most probably with misconfiguration from me.
By putting all my typescript functions in the same level (that means inside functions's folder) the files are transpiled to javascript and moved to the correct folder described in netlify.toml. But I want them to keep the structure that I want inside a folder with the same name as the function name, just like it's in the docs of netlify-dev.
Working structure:
functions
¦_node-fetch.ts
¦_hello-world.ts
What I desire:
functions
¦_node-fetch/node-fetch.ts
¦_hello-world/hello-world.ts
Because i want to have my functions with their own package.json
The vanilla javascript functions works well with the folder structure that I desire.
Thanks for the response!
process.env.VARIABLE_NAME
.2020-07-05T16:37:05.769Z 2ed6bae0-3702-441a-97b3-ad7cece3e9de Task timed out after 10.01 seconds
. What's really weird is that I can see the output being returned correctly in the logs. Also looking for some advice , hope someone can help!
submission-created
and hit it externally. It's reserved for form submissions. So don't go making any custom functions with these names lol https://docs.netlify.com/functions/trigger-on-events/#available-triggers
const express = require("express");
const serverless = require("serverless-http");
const app = express();
const router = express.Router();
app.use(express.static('model'));
router.get("/", (req, res) => {
res.json({ message: "api working!" })
});
app.use("/.netlify/functions/api", router);
module.exports.handler = serverless(app);
exports.handler = async () => {
return {
statusCode: 200,
body: JSON.stringify({ ratingCount: 5 }),
}
}
#server_name _;
server_name test.com;
ssl_certificate /etc/tech.crt;
ssl_certificate_key /etc/tech.key;
root /var/www/html;
#root /usr/share/nginx/html/;
index index.html;
auth_basic "Private Property";
auth_basic_user_file /etc/nginx/.htpasswd;}