blob: 28146b50b1084d0af2912a2a0c8c2e70720a59b7 [file] [log] [blame]
Matteo Scandolo86f3f282016-08-11 11:21:33 -07001(function () {
2 'use strict';
3 angular.module('xos.UITutorial')
4 .service('ResponseHandler', function(){
5 this.parse = (res, done) => {
6 // TODO @Arpit format res (it can be an array or an object),
7 // it is better if the output is a valid JSON (that we can copy and paste)
8 // TODO handle 204/No-Content response
9 if(angular.isArray(res)){
10 res = res.map(i => {
11 return JSON.stringify(i, ['id', 'name', 'max_instances'], 2) + '<br/>';
12 });
13 }
14 else {
15 res = JSON.stringify(res, ['id', 'name', 'max_instances'], 2);
16 }
17
18 done(res);
19 };
20 });
21})();