Help

Not able to use filter by formula (filterByFormula) in node.js (javascript)

2020 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Sneh_Erande
4 - Data Explorer
4 - Data Explorer

Hello,

I am new to API and node.js and I was trying to use filterbyformula for checking if an passcode (from airtable) matches with a local variable (inside the javascript file). But I am not understanding why I am getting value as undefined.

This is the table snip.
passcode snip



// Airtable variables
var Airtable = require('airtable');
var userRecord = new Airtable({apiKey: "xxxxxxxxxx"}).base("xxxxxxxx");
var Users = userRecord("Users");

var Local_passcode = '123346';

async function SendOtp() {
    const records = await Users.select({filterByFormula: `{Passcode} = "${Local_passcode}"`}).firstPage(function(err,records) {
        if(err) {
            console.log(err);
            return;
        }
        return records[0]
    })

    console.log(records);
}

SendOtp();


Can anyone help me on this?

Thanks in advance!!

2 Replies 2
Sneh_Erande
4 - Data Explorer
4 - Data Explorer

Hello,

Just solved the issue the data type of the passcode was not string so that’s why the error was occurring.

Sneh.

Thank you for sharing the solution. However, in your screen capture, it does look like the passcode is a string. Was there more going on?