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 {
|
||||
width: 30em;
|
||||
max-width: 100%;
|
||||
}
|
||||
.messages .message {
|
||||
display: inline-block;
|
||||
|
|
|
@ -31,7 +31,9 @@ class Api {
|
|||
req.set('Accept', 'application/json')
|
||||
.end((error, response) => {
|
||||
if (error) {
|
||||
reject(response.body);
|
||||
reject(response && response.body ? response.body : {
|
||||
'title': 'Networking error',
|
||||
'description': error.message});
|
||||
} else {
|
||||
resolve(response.body);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class BaseView {
|
|||
const messagesHolder = this.contentHolder.querySelector('.messages');
|
||||
/* TODO: animate this */
|
||||
const node = document.createElement('div');
|
||||
node.innerHTML = message;
|
||||
node.innerHTML = message.replace(/\n/g, '<br/>');
|
||||
node.classList.add('message');
|
||||
node.classList.add(className);
|
||||
messagesHolder.appendChild(node);
|
||||
|
|
Loading…
Reference in a new issue