Matteo Scandolo | 86f3f28 | 2016-08-11 11:21:33 -0700 | [diff] [blame] | 1 | (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 | })(); |