chore: improve error checking for no api url
continuous-integration/drone/pr Build is passing
Details
continuous-integration/drone/pr Build is passing
Details
This commit is contained in:
parent
06b2632fb5
commit
1cd5b41c96
|
@ -44,8 +44,7 @@ import ApiConfig from '@/components/misc/api-config'
|
||||||
import NoAuthWrapper from '@/components/misc/no-auth-wrapper'
|
import NoAuthWrapper from '@/components/misc/no-auth-wrapper'
|
||||||
import {mapState} from 'vuex'
|
import {mapState} from 'vuex'
|
||||||
import {ONLINE} from '@/store/mutation-types'
|
import {ONLINE} from '@/store/mutation-types'
|
||||||
|
import {ERROR_NO_API_URL} from '@/helpers/checkAndSetApiUrl'
|
||||||
const ERROR_NO_API_URL = 'noApiUrlProvided'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'ready',
|
name: 'ready',
|
||||||
|
@ -76,11 +75,6 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
load() {
|
load() {
|
||||||
if (window.API_URL === '') {
|
|
||||||
this.error = ERROR_NO_API_URL
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$store.dispatch('loadApp')
|
this.$store.dispatch('loadApp')
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
this.error = e
|
this.error = e
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
const API_DEFAULT_PORT = '3456'
|
const API_DEFAULT_PORT = '3456'
|
||||||
|
|
||||||
|
export const ERROR_NO_API_URL = 'noApiUrlProvided'
|
||||||
|
|
||||||
export const checkAndSetApiUrl = (url: string, updateConfig: () => Promise<void>): Promise<string> => {
|
export const checkAndSetApiUrl = (url: string, updateConfig: () => Promise<void>): Promise<string> => {
|
||||||
// Check if the url has an http prefix
|
// Check if the url has an http prefix
|
||||||
if (
|
if (
|
||||||
|
@ -106,6 +108,7 @@ export const checkAndSetApiUrl = (url: string, updateConfig: () => Promise<void>
|
||||||
localStorage.setItem('API_URL', window.API_URL)
|
localStorage.setItem('API_URL', window.API_URL)
|
||||||
return window.API_URL
|
return window.API_URL
|
||||||
}
|
}
|
||||||
return ''
|
|
||||||
|
throw new Error(ERROR_NO_API_URL)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue