From 037078d623f574ecf7a8b1ca9a204763e68688f3 Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Mon, 5 Nov 2018 21:00:12 +0000 Subject: [PATCH] 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. --- src/views/splash/splash.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/views/splash/splash.jsx b/src/views/splash/splash.jsx index 9eac6b052..06655fd96 100644 --- a/src/views/splash/splash.jsx +++ b/src/views/splash/splash.jsx @@ -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}); });