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

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.



// 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!!

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?

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.