Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
Passing variables to from an API request in to a response using NextJS

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' });
    }
    
    }
    
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!