fix fetch error

This commit is contained in:
hubery.wang 2020-12-09 22:11:22 +08:00
parent b5843cc086
commit 85641755a3

View File

@ -1,6 +1,7 @@
import Vue from 'vue' import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
import fetch from '@/utils/fetch' import fetch from '@/utils/fetch'
import { Message } from 'element-ui'
Vue.use(Vuex) Vue.use(Vuex)
const state = { const state = {
@ -17,8 +18,9 @@ const actions = {
async fetchServerInfo({ commit }) { async fetchServerInfo({ commit }) {
const res = await fetch('serverinfo') const res = await fetch('serverinfo')
if (!res.ok) { if (!res.ok) {
this.$message.warning('Get server info from frps failed!') Message.warning('Get server info from frps failed!')
commit('SET_SERVER_INFO', null) commit('SET_SERVER_INFO', null)
return
} }
commit('SET_SERVER_INFO', (await res.json()) || null) commit('SET_SERVER_INFO', (await res.json()) || null)