c-hive / dotdev

Next.js SPA professional website template for teams and individuals: https://c-hive.github.io/dotdev/
MIT License
0 stars 1 forks source link

Project should not be displayed in case of an error #122

Closed gomorizsolt closed 4 years ago

gomorizsolt commented 4 years ago

As-is: the component occupies the space and the star icon appears even if there's an error while fetching from the GitHub API:

CleanShot 2020-05-04 at 10 08 48

It's because if the fetch fails, the response is still valid to be parsed to json:

{message: "Not Found", documentation_url: "https://developer.github.com/v3/repos/#get"}

Expectation: log an error to the console (optionally display an error message in place of the component).

Proposal: utilize the well-tested safeParseJson() function (this way the outcome of the fetch depends on its ok property).

gomorizsolt commented 4 years ago

Resolved by #132.