Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!