mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2026-02-05 17:56:53 +01:00
fix json parsing error
This commit is contained in:
@@ -43,7 +43,13 @@ export default class NewsSection extends React.Component<IProps, IState> {
|
|||||||
async showLatestCommits() {
|
async showLatestCommits() {
|
||||||
if (!this.state.commitList) {
|
if (!this.state.commitList) {
|
||||||
const commits: string = await invoke('req_get', { url: 'https://api.grasscutters.xyz/cultivation/query' })
|
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 it didn't work, use official API
|
||||||
if (!obj.commits) {
|
if (!obj.commits) {
|
||||||
|
|||||||
Reference in New Issue
Block a user