JSON message along with Status
Fixing issue #74 in Utopian - Projects showing on different profile
Analyzing the Bug
Sometimes it is not enough to send only the status 404 as a response because frontend expects some message along with it. If the message is not supplied, frontend waits for the response for some time and then finally at the time out it says "No Message Supplied". In that waiting period, if you have come from any other's projects section, the projects of that person will be shown in your profile because front end still waits for the server to get appropriate message.
Fixing the Bug
Fixing Bug is relatively simple, it is just that we need to add a JSON message along with the status as shown below
For 404 Status
res.status(404).json({
message: 'Cannot find project for this account'
});
For 403 Status
res.status(403).json({
message: 'Server refuses to give details of the account'
})
Commit : https://github.com/utopian-io/api.utopian.io/pull/28/commits/d05cfc53c7234ce864daf1677f8a0956d7440752 Pull request : https://github.com/utopian-io/api.utopian.io/pull/28
Validation
Posted on Utopian.io - Rewarding Open Source Contributors