aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/rest/rest-extractor.service.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-06-16 14:32:15 +0200
commitdf98563e2104b82b119c00a3cd83cd0dc1242d25 (patch)
treea9720bf01bac9ad5646bd3d3c9bc7653617afdad /client/src/app/shared/rest/rest-extractor.service.ts
parent46757b477c1adb5f98060d15998a3852e18902a6 (diff)
downloadPeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.gz
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.tar.zst
PeerTube-df98563e2104b82b119c00a3cd83cd0dc1242d25.zip
Use typescript standard and lint all files
Diffstat (limited to 'client/src/app/shared/rest/rest-extractor.service.ts')
-rw-r--r--client/src/app/shared/rest/rest-extractor.service.ts48
1 files changed, 24 insertions, 24 deletions
diff --git a/client/src/app/shared/rest/rest-extractor.service.ts b/client/src/app/shared/rest/rest-extractor.service.ts
index fcb1598f4..f6a818ec8 100644
--- a/client/src/app/shared/rest/rest-extractor.service.ts
+++ b/client/src/app/shared/rest/rest-extractor.service.ts
@@ -1,52 +1,52 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core'
2import { Response } from '@angular/http'; 2import { Response } from '@angular/http'
3import { Observable } from 'rxjs/Observable'; 3import { Observable } from 'rxjs/Observable'
4 4
5export interface ResultList { 5export interface ResultList {
6 data: any[]; 6 data: any[]
7 total: number; 7 total: number
8} 8}
9 9
10@Injectable() 10@Injectable()
11export class RestExtractor { 11export class RestExtractor {
12 12
13 constructor () { ; } 13 extractDataBool (res: Response) {
14 14 return true
15 extractDataBool(res: Response) {
16 return true;
17 } 15 }
18 16
19 extractDataList(res: Response) { 17 extractDataList (res: Response) {
20 const body = res.json(); 18 const body = res.json()
21 19
22 const ret: ResultList = { 20 const ret: ResultList = {
23 data: body.data, 21 data: body.data,
24 total: body.total 22 total: body.total
25 }; 23 }
26 24
27 return ret; 25 return ret
28 } 26 }
29 27
30 extractDataGet(res: Response) { 28 extractDataGet (res: Response) {
31 return res.json(); 29 return res.json()
32 } 30 }
33 31
34 handleError(res: Response) { 32 handleError (res: Response) {
35 let text = 'Server error: '; 33 let text = 'Server error: '
36 text += res.text(); 34 text += res.text()
37 let json = ''; 35 let json = ''
38 36
39 try { 37 try {
40 json = res.json(); 38 json = res.json()
41 } catch (err) { ; } 39 } catch (err) {
40 console.error('Cannot get JSON from response.')
41 }
42 42
43 const error = { 43 const error = {
44 json, 44 json,
45 text 45 text
46 }; 46 }
47 47
48 console.error(error); 48 console.error(error)
49 49
50 return Observable.throw(error); 50 return Observable.throw(error)
51 } 51 }
52} 52}