From 54a6583f93b9630ef5723d1e2bb693742e874806 Mon Sep 17 00:00:00 2001 From: Tosin Date: Sun, 22 Dec 2024 09:39:05 +0100 Subject: [PATCH] declare and intialize body variable index.js defined body varibale to fix error: {"message":"Failed to perform operation.","errorMsg":"body is not defined","errorStack":"ReferenceError: body is not defined\n at exports.handler (/var/task/index.js:24226:16)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"} --- Section 19/End/aws-microservices/src/product/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Section 19/End/aws-microservices/src/product/index.js b/Section 19/End/aws-microservices/src/product/index.js index 6235083..5ba9a53 100644 --- a/Section 19/End/aws-microservices/src/product/index.js +++ b/Section 19/End/aws-microservices/src/product/index.js @@ -7,6 +7,8 @@ exports.handler = async function(event) { console.log("request:", JSON.stringify(event, undefined, 2)); try { + let body = null; + switch (event.httpMethod) { case "GET": if(event.queryStringParameters != null) { @@ -191,4 +193,4 @@ const getProductsByCategory = async (event) => { console.error(e); throw e; } -} \ No newline at end of file +}