I'm using the Airtbale API and want to filter a response using variables collected from a React form. I've consoled the response from the form and the variables exist. Also If I hard code the variables (name, surname) into the Airtable's filterByFormula the response is successful. However, if I try to pass variables from the API response I get a server error 500. Could it be cors?
Error from the network tab
Request URL: http://localhost:3000/api/rsvp
Request Method: POST
Status Code: 500 Internal Server Error
Remote Address: [::1]:3000
Referrer Policy: strict-origin-when-cross-origin
Code below
import { table, minifyRecords } from '../../utils/Airtable';
export default async (req , res) => {
const {name,surname} = req.body //<--this consoles data gathered from a form correctly
`
try {
console.log(surname)
console.log(name)
const records = await table.select({filterByFormula:`OR({name} = ${name}, {surname} = ${surname})`}).firstPage();
const minifiedRecords = minifyRecords(records);
res.statusCode = 200;
res.json(minifiedRecords);
} catch (err) {
res.statusCode = 500;
res.json({ msg: 'Something went wrong' });
}
}