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

Seraching according a feild in Airtable

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

Hi everyone, I am writing a micro-service where I want to accept a field, look for its record, and return with data from its record. Ideally, I also want to make it not case-sensitive. But I am having multiple issues with it. Firstly, unwrapping the string is “SELECT” is not working for me. It works if I just pass a string but not when I try to unwrap a variable (according to a solution I found on this forum. Secondly, how do I make it not case sensitive? is this possible if I have to write something custom (as in fetching everything and manually search through).

Here is my current code.

export const getDefinition = async (userInput: String) => {
console.log('this is from getDefinition!!!', userInput)

//configure Airtable//
Airtable.configure({
    endpointUrl : process.env.AIRTABLE_URL,
    apiKey: process.env.AIRTABLE_API_KEY
})


const data = base(process.env.AIRTABLE_TABLE_NAME).select({
    filterByFormula : `{term} = "${userInput}"`
}).eachPage((records: any, fetchNextPage: any) => {
    records.forEach((record: any) => {
        let termDefinition = record.fields.definition
        console.log(termDefinition)
        return termDefinition
    })
    // fetchNextPage()
}, (err: Error) => {
    console.error('Error: ', err)
})

}

0 Replies 0