client/api: handle connection errors
This commit is contained in:
parent
583e73dfc7
commit
60a677edf4
3 changed files with 5 additions and 2 deletions
|
@ -112,6 +112,7 @@ nav.text-nav ul li.active a {
|
||||||
|
|
||||||
.messages {
|
.messages {
|
||||||
width: 30em;
|
width: 30em;
|
||||||
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
.messages .message {
|
.messages .message {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
|
@ -31,7 +31,9 @@ class Api {
|
||||||
req.set('Accept', 'application/json')
|
req.set('Accept', 'application/json')
|
||||||
.end((error, response) => {
|
.end((error, response) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
reject(response.body);
|
reject(response && response.body ? response.body : {
|
||||||
|
'title': 'Networking error',
|
||||||
|
'description': error.message});
|
||||||
} else {
|
} else {
|
||||||
resolve(response.body);
|
resolve(response.body);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ class BaseView {
|
||||||
const messagesHolder = this.contentHolder.querySelector('.messages');
|
const messagesHolder = this.contentHolder.querySelector('.messages');
|
||||||
/* TODO: animate this */
|
/* TODO: animate this */
|
||||||
const node = document.createElement('div');
|
const node = document.createElement('div');
|
||||||
node.innerHTML = message;
|
node.innerHTML = message.replace(/\n/g, '<br/>');
|
||||||
node.classList.add('message');
|
node.classList.add('message');
|
||||||
node.classList.add(className);
|
node.classList.add(className);
|
||||||
messagesHolder.appendChild(node);
|
messagesHolder.appendChild(node);
|
||||||
|
|
Loading…
Reference in a new issue