mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-23 07:38:07 -05:00
Avoid displaying an error when /news returns a 500
This situation probably occurs most frequently when running dev servers while offline, but could also happen if the API is having issues. 500 responses from the API should not take down the homepage so drastically, and are also sometimes unavoidable while working offline.
This commit is contained in:
parent
6d8235c7e8
commit
037078d623
1 changed files with 4 additions and 1 deletions
|
@ -71,7 +71,10 @@ class Splash extends React.Component {
|
|||
getNews () {
|
||||
api({
|
||||
uri: '/news?limit=3'
|
||||
}, (err, body) => {
|
||||
}, (err, body, resp) => {
|
||||
if (resp.statusCode !== 200) {
|
||||
return log.error(`Unexpected status code ${resp.statusCode} received from news request`);
|
||||
}
|
||||
if (!body) return log.error('No response body');
|
||||
if (!err) return this.setState({news: body});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue