bloominstituteoftechnology / web-sprint-challenge-build-a-web-api

2 stars 1.44k forks source link

bug in mappers logic when using middleware #13

Open AmadoGuerrero opened 3 years ago

AmadoGuerrero commented 3 years ago

If you don't use middleware, there is no problem, the mappers work fine. But if you decide to use middlware to verify if the projectId is valid (like I did) you will run across a bug because the projectToBody mapper function will get called twice. (Once when checking the id, and another when returning the updated field). so when intToBoolean runs the second time, it will be comparing true/false to 1 and that will always be false (even if the action has been completed). I had to change line 9 in mappers.js from return int === 1 ? true : false; to return int === 1 || int === true ? true : false; for it to work for me.

DrSumner commented 2 months ago

Im having this same problem, and came to this same conclusion but wasn't sure if id be allowed to change it. Ill go ahead and make that same change so I can be done with this. hopefully, they patch that. the intToBoolean is too strict IMO