mirror of
https://github.com/wahyd4/docsify.git
synced 2026-08-09 05:16:06 +10:00
add catch ajax error
This commit is contained in:
+2
-1
@@ -5,6 +5,7 @@ export default function (url, options = {}) {
|
||||
xhr.send()
|
||||
|
||||
return {
|
||||
then: cb => xhr.addEventListener('load', cb)
|
||||
then: cb => xhr.addEventListener('load', cb),
|
||||
catch: cb => xhr.addEventListener('error', cb)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -40,7 +40,8 @@ class Docsify {
|
||||
}
|
||||
|
||||
load () {
|
||||
ajax(`${this.loc}.md`).then(res => {
|
||||
ajax(`${this.loc}.md`)
|
||||
.then(res => {
|
||||
const target = res.target
|
||||
if (target.status >= 400) {
|
||||
this.render('not found')
|
||||
@@ -52,6 +53,7 @@ class Docsify {
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(_ => this.render('not found'))
|
||||
}
|
||||
|
||||
render (content) {
|
||||
|
||||
Reference in New Issue
Block a user