scoreboard
scoreboard copied to clipboard
Team detail page needs to handle api errors from osm-teams api
If you mark a team as private
in the osm-teams database, and then try to load the scoreboard page team/{id}
a React error in pages/team.js because of a missing prop:
TypeError: osmesaStats is undefined
render
./pages/team.js:21
18 | this.slugger = new Slugger()
19 | }
20 |
> 21 | render () {
22 | const { team } = this.props
23 | if (!team) return <div />
24 |
Here is the console error from osm-teams:
teams_1 | [1586558044957] INFO (27 on 88da7e74827a): request completed
teams_1 | module: "manage"
teams_1 | req: {
teams_1 | "id": 79,
teams_1 | "method": "GET",
teams_1 | "url": "/api/teams/3",
teams_1 | "headers": {
teams_1 | "host": "localhost:8989",
teams_1 | "connection": "close"
teams_1 | }
teams_1 | }
teams_1 | res: {
teams_1 | "statusCode": 401,
teams_1 | "headers": {
teams_1 | "x-powered-by": "Express",
teams_1 | "access-control-allow-origin": "*",
teams_1 | "content-type": "application/json; charset=utf-8",
teams_1 | "content-length": "63",
teams_1 | "etag": "W/\"3f-rJtZaqqTZoZmt8x9Vb0DIX1WuSM\"",
teams_1 | "set-cookie": [
teams_1 | "osm-teams.sid=s%3AtY_4oi_WZ-1-FY_sKymrbnABbuLlkfL8.F84gZYyiyqaKTrPGfX0%2FIGBnAqodOTR%2Fopm8zcDv%2Bc0; Path=/; HttpOnly"
teams_1 | ],
teams_1 | "vary": "Accept-Encoding"
teams_1 | }
teams_1 | }
teams_1 | responseTime: 11
The correct behavior would be to handle the 401 error before the React component tries to render, and display a unified 401 unauthorized page, anytime this occurs in the app.