Exercise tracker finished

Exercise tracker finished
0

#1

Just finished my exercise tracker. Bit nervous there may be a few lingering bugs. Would really appreciate any time people could put into breaking it. Also any general constructive criticism is greatly appreciated. Thanks in advance :slight_smile:

App: https://yummy-brow.glitch.me/
Code: https://github.com/npwilliams09/FCC-Back-End/tree/master/Excercise%20Tracker


#2

Hi,

Didn’t spend much time, but you have a huge bug in your code that makes the app unusable:

app.post('/api/exercise/new-user',(req,res) => {
  createPerson(req.body.username, (err,saveData)=>{
    if(err){
      res.send({error:"Error, Please try again"});
    }else if (saveData = 'taken'){
      res.send({"error":"Username already taken"})
    }else{
      res.send({"username":saveData.username,"id":saveData.shortId});
    }
  });
});

Can you spot the bug? :slight_smile:


#3

ahhh last thing I added. Think i was just a bit excited at that point :stuck_out_tongue: Changed it to a triple = sign. Just want to check this was the bug you were referring to?


#4

Yep, that’s what I meant. Now it works like a charm. Good job!


#5

Thanks for your help :slight_smile:


#6

Is there no way to query the database for dates within the range? Is the only option to grab all and then only display the ones within the date?


#7

You could store dates in ‘milliseconds from 1.1.1970.’ format and use .gt('date', from) and .lt('date', to) on your queries. But, then you need to have two separate models, one for a user and one for a log of exercises. And then you need to connect log with a related user.

PS I assumed you use mongoose.