If I pass the input of 1//2mi to your app, it should return invalid number. Instead, you return {"initNum":0.5,"initUnit":"mi","returnNum":0.80467,"returnUnit":"km","string":"0.5 miles converts to 0.80467 kilometers"}.
Another example is if I pass e1mi, it should return invalid number. Instead you return "invalid unit".
There are two issues going on here. First, your logic is not correctly determining when to realize an invalid number has been passed. The other issue, is that you are using res.json() instead of res.send(). To pass back just a string response, you should use res.send().