Code cleanup
This commit is contained in:
parent
2fba3427cc
commit
89ca44069b
1 changed files with 22 additions and 18 deletions
|
@ -30,6 +30,26 @@ import SpellList from './Spelllist'
|
||||||
|
|
||||||
Vue.component('spell-list', SpellList)
|
Vue.component('spell-list', SpellList)
|
||||||
|
|
||||||
|
function fetchSuccess (data) {
|
||||||
|
dispatch({
|
||||||
|
type: 'SPELLS_RESOLVED',
|
||||||
|
data: {
|
||||||
|
data,
|
||||||
|
loaded: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function fetchFailure (reason) {
|
||||||
|
let message = 'Unable to retrieve spells list'
|
||||||
|
Dialog.create({
|
||||||
|
title: 'Error',
|
||||||
|
message,
|
||||||
|
nobuttons: true
|
||||||
|
})
|
||||||
|
console.error(message, reason)
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
@ -43,24 +63,8 @@ export default {
|
||||||
|
|
||||||
fetch('./statics/dnd5e.json')
|
fetch('./statics/dnd5e.json')
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(spells => {
|
.then(fetchSuccess)
|
||||||
dispatch({
|
.catch(fetchFailure)
|
||||||
type: 'SPELLS_RESOLVED',
|
|
||||||
data: {
|
|
||||||
loaded: true,
|
|
||||||
data: spells
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
let message = 'Unable to retrieve spells list'
|
|
||||||
Dialog.create({
|
|
||||||
title: 'Error',
|
|
||||||
message,
|
|
||||||
nobuttons: true
|
|
||||||
})
|
|
||||||
console.error(message, reason)
|
|
||||||
})
|
|
||||||
.then(() => { Loading.hide() })
|
.then(() => { Loading.hide() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue