io-ng-util
Advanced tools
Comparing version 4.1.2 to 4.2.0
@@ -6,8 +6,9 @@ import 'rxjs/add/operator/catch'; | ||
import 'rxjs/add/observable/throw'; | ||
import { Env } from './env'; | ||
export declare class HttpService { | ||
private http; | ||
private jsonp; | ||
private env; | ||
private headers; | ||
private options; | ||
constructor(http: Http, jsonp: Jsonp); | ||
constructor(http: Http, jsonp: Jsonp, env: Env); | ||
httpGet(url: string): Observable<any[]>; | ||
@@ -18,2 +19,3 @@ httpPost(url: string, body: any, flatten?: boolean): Observable<any[]>; | ||
private extractData(res); | ||
private makeHeaders(); | ||
} |
@@ -9,14 +9,11 @@ 'use strict'; | ||
require("rxjs/add/observable/throw"); | ||
var env_1 = require("./env"); | ||
var HttpService = (function () { | ||
function HttpService(http, jsonp) { | ||
function HttpService(http, jsonp, env) { | ||
this.http = http; | ||
this.jsonp = jsonp; | ||
this.headers = new http_1.Headers({ | ||
'Authorization': 'Bearer xxxxx', | ||
'Content-Type': 'application/json', | ||
}); | ||
this.options = new http_1.RequestOptions({ headers: this.headers }); | ||
this.env = env; | ||
} | ||
HttpService.prototype.httpGet = function (url) { | ||
return this.http.get(url, this.options) | ||
return this.http.get(url, this.makeHeaders()) | ||
.map(this.extractData) | ||
@@ -29,3 +26,3 @@ .catch(this.handleError); | ||
: JSON.stringify(flattenObject(body)); | ||
return this.http.post(url, values, this.options) | ||
return this.http.post(url, values, this.makeHeaders()) | ||
.map(this.extractData) | ||
@@ -35,3 +32,3 @@ .catch(this.handleError); | ||
HttpService.prototype.jsonpGet = function (url) { | ||
return this.jsonp.get(url, this.options) | ||
return this.jsonp.get(url, this.makeHeaders()) | ||
.map(this.extractData) | ||
@@ -67,2 +64,12 @@ .catch(this.handleError); | ||
}; | ||
HttpService.prototype.makeHeaders = function () { | ||
var h = { | ||
'Content-Type': 'application/json', | ||
}; | ||
if (this.env.user.token) { | ||
h.Authorization = this.env.user.token; | ||
} | ||
this.headers = new http_1.Headers(h); | ||
return new http_1.RequestOptions({ headers: this.headers }); | ||
}; | ||
HttpService.decorators = [ | ||
@@ -74,2 +81,3 @@ { type: core_1.Injectable }, | ||
{ type: http_1.Jsonp, }, | ||
{ type: env_1.Env, }, | ||
]; }; | ||
@@ -76,0 +84,0 @@ return HttpService; |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"HttpService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"},{"__symbolic":"reference","module":"@angular/http","name":"Jsonp"}]}],"httpGet":[{"__symbolic":"method"}],"httpPost":[{"__symbolic":"method"}],"jsonpGet":[{"__symbolic":"method"}],"handleError":[{"__symbolic":"method"}],"extractData":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"HttpService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"},{"__symbolic":"reference","module":"@angular/http","name":"Jsonp"}]}],"httpGet":[{"__symbolic":"method"}],"httpPost":[{"__symbolic":"method"}],"jsonpGet":[{"__symbolic":"method"}],"handleError":[{"__symbolic":"method"}],"extractData":[{"__symbolic":"method"}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"HttpService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"},{"__symbolic":"reference","module":"@angular/http","name":"Jsonp"},{"__symbolic":"reference","module":"./env","name":"Env"}]}],"httpGet":[{"__symbolic":"method"}],"httpPost":[{"__symbolic":"method"}],"jsonpGet":[{"__symbolic":"method"}],"handleError":[{"__symbolic":"method"}],"extractData":[{"__symbolic":"method"}],"makeHeaders":[{"__symbolic":"method"}]}}}},{"__symbolic":"module","version":1,"metadata":{"HttpService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/http","name":"Http"},{"__symbolic":"reference","module":"@angular/http","name":"Jsonp"},{"__symbolic":"reference","module":"./env","name":"Env"}]}],"httpGet":[{"__symbolic":"method"}],"httpPost":[{"__symbolic":"method"}],"jsonpGet":[{"__symbolic":"method"}],"handleError":[{"__symbolic":"method"}],"extractData":[{"__symbolic":"method"}],"makeHeaders":[{"__symbolic":"method"}]}}}}] |
{ | ||
"name": "io-ng-util", | ||
"version": "4.1.2", | ||
"version": "4.2.0", | ||
"description": "Angular Base Utilities", | ||
@@ -18,19 +18,19 @@ "main": "index.js", | ||
"devDependencies": { | ||
"@angular/common": "^4.3.6", | ||
"@angular/compiler": "^4.3.6", | ||
"@angular/compiler-cli": "^4.3.6", | ||
"@angular/core": "^4.3.6", | ||
"@angular/http": "^4.3.6", | ||
"@angular/platform-browser": "^4.3.6", | ||
"@angular/platform-server": "^4.3.6", | ||
"@angular/common": "^4.4.4", | ||
"@angular/compiler": "^4.4.4", | ||
"@angular/compiler-cli": "^4.4.4", | ||
"@angular/core": "^4.4.4", | ||
"@angular/http": "^4.4.4", | ||
"@angular/platform-browser": "^4.4.4", | ||
"@angular/platform-server": "^4.4.4", | ||
"@ngrx/core": "^1.2.0", | ||
"@types/core-js": "^0.9.43", | ||
"@types/node": "^8.0.26", | ||
"codelyzer": "^3.1.2", | ||
"eslint": "^4.5.0", | ||
"@types/node": "^8.0.32", | ||
"codelyzer": "^3.2.0", | ||
"eslint": "^4.8.0", | ||
"rxjs": "^5.4.3", | ||
"tslint": "^5.7.0", | ||
"tslint-eslint-rules": "^4.1.1", | ||
"typescript": "^2.5.1", | ||
"zone.js": "^0.8.17" | ||
"typescript": "^2.5.3", | ||
"zone.js": "^0.8.18" | ||
}, | ||
@@ -37,0 +37,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59403
758