Hi,
I am trying to call AirTable from inside a Lambda function using a local instance (using AWS SAM).
If I just use node/js as is, it all works fine (so I know the code should work). But once I put it inside the Lambda and try to run it, I see nothing in the console.
Any clues as to what is going on?
This is the code I am running
let response;
exports.lambdaHandler = async (event, context) => {
var Airtable = require('airtable');
var base = new Airtable({apiKey: 'k***************3'}).base('ap****************8jC');
base('Course Locations').select({
maxRecords: 3,
view: "Myview"
}).eachPage(function page(records, fetchNextPage) {
records.forEach(function(record) {
console.log('Retrieved');//, record.get('Name (Abbrev.)')
});
}, function done(err) {
if (err) {
console.error(err);
return;
}
});
try {
response = {
'statusCode': 200,
'body': JSON.stringify({
message: 'hello world',
})
}
} catch (err) {
console.log(err);
return err;
}
return response
};
I do see the “hello world” in the log/response.
The code as is runs well when I use it in a simple javascript file and run it with node.
In simple node, I do see the console.log('Retrieved');
but not inside a lmbda