Skip to content

Commit 058b193

Browse files
committed
Improve handling of errors in fetch call
1 parent 278fd2d commit 058b193

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

dash/dash-renderer/src/components/error/menu/VersionInfo.react.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,21 @@ async function requestDashVersionInfo(config) {
6060
}
6161
})
6262
.then(response => response.json())
63-
.catch(() => {})
63+
.catch(() => {
64+
return {};
65+
})
6466
.then(body => {
65-
localStorage.setItem(
66-
'cachedNewDashVersion',
67-
JSON.stringify(body.version)
68-
);
69-
localStorage.setItem('cachedNewDashVersionLink', body.link);
70-
localStorage.setItem('lastFetched', Date.now());
71-
return body;
67+
if (body.version && body.link) {
68+
localStorage.setItem(
69+
'cachedNewDashVersion',
70+
JSON.stringify(body.version)
71+
);
72+
localStorage.setItem('cachedNewDashVersionLink', body.link);
73+
localStorage.setItem('lastFetched', Date.now());
74+
return body;
75+
} else {
76+
return {};
77+
}
7278
});
7379
}
7480
}

0 commit comments

Comments
 (0)