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

123
Vistas
Exit if statement and continue with next code

So I got this if statement that checks whether media file is type of image. Whether is true, how can I exit this if statement and continue to next lines of codes where is await... ?

When I added : continue I am getting error expression expected.

   if(mediaValue.value == 'image') {
          const validateMedia = mediaFile.value.files[0].type.indexOf("image/") > -1

          return validateMedia == false ? showToast("notImageFile", "error") : continue;
        }
        await createData(
          route.params.shopid,
          route.params.id,
          params
        );
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You don't return from an if. If you want it not to show the toast popup in a certain situation then simply add another if so the code will skip that command when the condition isn't met. For example

if (validateMedia == false) showToast("notImageFile", "error");

After that the code will exit the if block naturally and continue with the next command.

P.S. If you want the processing to pause when the toast popup shows that's a slightly separate question...

about 4 years ago · Juan Pablo Isaza Denunciar

0

Don't return in the if statement. That'll solve your problem. When you return, you return from the function and no more execution ( The async call) will happen.

about 4 years ago · Juan Pablo Isaza Denunciar

0

shouldn't this normally work?

      if(mediaValue.value == 'image') {
              const validateMedia = mediaFile.value.files[0].type.indexOf("image/") > -1
    // if validate media is false then it will return, if not then it will not return
              if( validateMedia == false)
              showToast("notImageFile", "error");
            }
            await createData(
              route.params.shopid,
              route.params.id,
              params
            );
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