Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

212
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda