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

220
Vistas
How to avoid inserting undefined in MySQL using nodejs and reactjs?

Is there a way to stop inserting an undefined value in MYSQL using reactjs?

so here is the code.

  const regex = /.*([A-Za-z0-9_\-]{11}).*/gi;

  if (postData.video_id) {
    postData.video_id = postData.video_id.replace(regex, "$1");
  }

and it keeps submitting undefined in the database, I need to make it optional either with value or empty, it is up to the user.

appreciate your help

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

the data might do not match with the regex, so validate the replace expression before assign it to postData.video_id :

  const regex = /.*([A-Za-z0-9_\-]{11}).*/gi;

  if (postData.video_id) {
    const videoId = postData.video_id.replace(regex, "$1");
    if(videoId) postData.video_id = videoId;
  }
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