I'm trying to follow the examples found here, but am not quite getting it. Here is what I have:
simpletest.js:
exports.handler = async (event) => {
console.log('>> Handler called');
const response = {
statusCode: 200,
body: JSON.stringify('Handler Data')
};
console.log('>> Response[1]: ' + JSON.stringify(response));
return response;
};
simplerun.js
let process = require('./simpletest.js');
console.log(">> START");
process.handler(
{}, // event
{}, // context
function(response,error) {
console.log(">> Response[2]: " + response);
}
);
console.log(">> END");
What I got:
% node simplerun.js
>> START
>> Handler called
>> Response[1]: {"statusCode":200,"body":"\"Handler Data\""}
>> END
What I expected:
% node simplerun.js
>> START
>> Handler called
>> Response[1]: {"statusCode":200,"body":"\"Handler Data\""}
>> Response[2]: {"statusCode":200,"body":"\"Handler Data\""}
>> END
Why isn't Response[2] being generated as expected?