Exercise tracker finished

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

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:

1 Like

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?

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

1 Like

Thanks for your help :slight_smile:

1 Like

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?

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.

Project Link → https://sameers-exercise-tracker.herokuapp.com/

Source Code → https://github.com/sameer-ingavale/NodeJS-Exercise-Tracker

Styling inspiration → https://www.freecodecamp.org/asimolovegym

Any feedback is appreciated! :smiley: