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

124
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
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