Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

272
Vistas
Nextjs: 405 when form submit POST

Following this tutorial, I'm trying to submit a form in Nextjs but get a 405 error when trying to POST to my api route. I've tried using both axios and the fetch api. This seems like it should be simple to do but I'm not sure where I'm going wrong. Anything obvious I'm missing? Thanks!

/survey/create

const handleSubmit = async (event) => {
    event.preventDefault();

    const testData = {
      title: surveyTitle,
    };

    const res = await fetch("/api/survey", {
      method: "POST",
      body: JSON.stringify({
        dataName: testData,
      }),
      headers: {
        "Content-Type": "application/json",
      },
    });
  };

/api/survey

export default function handler(req, res) {
  console.log(req.body);
  res.status(200).json(JSON.stringify({ name: 'Success' }))
}
about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda