I'm trying to call my appsync API in a lambda in my Amplify project so I want to use the aws-appsync library.
My lambda looks like this:
const AWSAppSyncClient = require("aws-appsync");
exports.handler = async (event) => {
console.log(event)
};
When running amplify mock function <myfunction>
or when running it in the AWS console.
This will throw an error:
{
stack: 'Error: Could not load lambda handler function due to TypeError: Cannot convert undefined or null to object\n' +
' at loadHandler (C:\\Users\\lalle\\nvm\\v12.18.0\\node_modules\\@aws-amplify\\cli\\node_modules\\amplify-nodejs-function-runtime-provider\\lib\\utils\\execute.js:106:15)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:97:5)',
message: 'Could not load lambda handler function due to TypeError: Cannot convert undefined or null to object'
}
What does this mean and how do I fix it?
I was running into this issue and it was because I was trying to use an environment variable that I'd forgotten to include. I had to update the permissions to give the lambda access to my API.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.