Is glitch.com currently..err, glitched?

I am currently at Api & microservices test number 3 : url shortener. Since this test requiring a form to submit the url, this is my form code:

<form method="POST" action="/api/shorturl/new/">
  Your URL:<br>
  <input type="text" name="myUrl" value="www.youtube.com">
  <br>
  <br><br>
  <input type="submit" value="Submit">
</form>

The problem is : everytime i pressed the form submit button, it take a very long for the glitch page to process that simple request, and when it is done, the result is always a big capital message : Site didn’t respond.

So, any help? Anyone else currently experiencing this?

you need to write code inside else statement for response i.e.

app.post('/api/shorturl/new', (req, res)=>{
  const {myUrl} = req.body;
  if(!validURL(myUrl)){
    res.json({error: 'invalid URL'});
  }else{
    dns.lookup(myUrl, function (err, address, family) {
      if(address===undefined){
        res.json({error: 'invalid Hostname'});
      }else{
        //Model.find here....
        res.json({success:"working fine"})
      }
    });
  }
})
1 Like

Ahh, yes, basically have to handle the response for every conditional branch. Thank you again!

Hello, sorry to bother you again, if you have the time please have a look at this question