Commit 932b7a8a authored by Moises Sacal's avatar Moises Sacal

fixed users notebooks when there is only one notebook

parent 6bf5d8f7
......@@ -86,7 +86,16 @@ var Controllers;
}
})
.subscribe(response => {
const notebooks = response['users']['notebooks'];
let resNotebooks = response['users']['notebooks'];
let notebooks = { '$': { type: 'array' }, notebook: [] };
if (Array.isArray(resNotebooks['notebook'])) {
notebooks['notebook'] = resNotebooks['notebook'];
}
else {
if (resNotebooks['notebook']) {
notebooks['notebook'] = [resNotebooks['notebook']];
}
}
this.ajaxOk(req, res, null, { status: true, notebooks: notebooks, message: 'list' });
}, error => {
sails.log.error('list: error');
......
......@@ -102,7 +102,15 @@ export module Controllers {
}
})
.subscribe(response => {
const notebooks = response['users']['notebooks'];
let resNotebooks = response['users']['notebooks'];
let notebooks = {'$': { type: 'array' }, notebook: []};
if(Array.isArray(resNotebooks['notebook'])) {
notebooks['notebook'] = resNotebooks['notebook'];
} else {
if(resNotebooks['notebook']){
notebooks['notebook'] = [resNotebooks['notebook']];
}
}
this.ajaxOk(req, res, null, {status: true, notebooks: notebooks, message: 'list'});
}, error => {
sails.log.error('list: error');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment