fix json parsing error

This commit is contained in:
SpikeHD
2022-05-15 15:58:17 -07:00
parent 4497d5c0e3
commit 11ad0e4453

View File

@@ -43,7 +43,13 @@ export default class NewsSection extends React.Component<IProps, IState> {
async showLatestCommits() {
if (!this.state.commitList) {
const commits: string = await invoke('req_get', { url: 'https://api.grasscutters.xyz/cultivation/query' })
let obj = JSON.parse(commits)
let obj
try {
obj = JSON.parse(commits)
} catch(e) {
obj = {}
}
// If it didn't work, use official API
if (!obj.commits) {