diff --git a/src/ajax.js b/src/ajax.js index 71e3fe0..0a1086c 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -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) } } diff --git a/src/index.js b/src/index.js index dba6d88..76bc696 100644 --- a/src/index.js +++ b/src/index.js @@ -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) {