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

301
Vistas
Destructuring 'req.body.data' into 'req.body'

I am sending some data from the front end to the back end. I am trying to send data as an object to the back. When it arrives, it is obviously req.body.data, but should land in the backend as req.body. How do I destructure the request, either from the front or the back so that the back only receives req.body

front end

const { user } = await axios.post('http://localhost:3000/auth/signup', {data});

Backend (what I want)

if(req.body.type === 'vendor') {

Right now the backend received (What i dont want)

if(req.body.data.type....)
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Your passing data as an object prop. Just pass it directly:

const { user } = await axios.post('http://localhost:3000/auth/signup', data)
about 4 years ago · Juan Pablo Isaza Denunciar

0

You are sending object with data property when sending request to the backend. What you should do is destruct that data object and send its property directly:

const { user } = await axios.post('http://localhost:3000/auth/signup', { ...data });
about 4 years ago · Juan Pablo Isaza Denunciar
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