I am trying to create a record on airtable and I am getting that createdRecords is “undefined”.
All the variables FirstName,LastName,Email,JobLevel print to console but then createdRecords is undefined.
const Airtable = require('airtable');
var base = new Airtable({apiKey: 'VARIABLE'}).base('VARIABLE');
const table = base('VARIABLE');
var FirstName = event.user.given_name;
var LastName = event.user.family_name;
var Email = event.user.email;
var JobLevel = event.connection.id;
console.log(FirstName,LastName,Email,JobLevel);
const createdRecords = await table.create([
{ fields: {FirstName, LastName, Email, JobLevel} },
]);
console.log(createdRecords);
This is all part of auth0 post login action that looks like this
exports.onExecutePostLogin = async (event, api) => {
const Airtable = require('airtable');
var base = new Airtable({apiKey: 'VARIABLE'}).base('VARIABLE');
const table = base('VARIABLE');
var FirstName = event.user.given_name;
var LastName = event.user.family_name;
var Email = event.user.email;
var JobLevel = event.connection.id;
console.log(FirstName,LastName,Email,JobLevel);
const createdRecords = await table.create([
{ fields: { FirstName, LastName, Email, JobLevel} },
]);
console.log(createdRecords);
};