Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Auth0 Log In action Create Record in Airtable

Topic Labels: API
302 0
cancel
Showing results for 
Search instead for 
Did you mean: 

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);
};
0 Replies 0