Fixed issue header not included in requests
Fixed issue httpclient returned response
This commit is contained in:
parent
c907155112
commit
dc767eb51c
File diff suppressed because one or more lines are too long
29
src/Web/WebMVC/wwwroot/js/site.min.js
vendored
Normal file
29
src/Web/WebMVC/wwwroot/js/site.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -81,7 +81,7 @@ export class BasketService {
|
|||||||
if (response.status === 204) {
|
if (response.status === 204) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return response.json();
|
return response;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export class CampaignsService {
|
|||||||
url = url + '?pageIndex=' + pageIndex + '&pageSize=' + pageSize;
|
url = url + '?pageIndex=' + pageIndex + '&pageSize=' + pageSize;
|
||||||
|
|
||||||
return this.service.get(url).pipe(map((response: Response) => {
|
return this.service.get(url).pipe(map((response: Response) => {
|
||||||
return response.json();
|
return response;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ export class CampaignsService {
|
|||||||
let url = this.marketingUrl + '/api/v1/m/campaigns/' + id;
|
let url = this.marketingUrl + '/api/v1/m/campaigns/' + id;
|
||||||
|
|
||||||
return this.service.get(url).pipe(map((response: Response) => {
|
return this.service.get(url).pipe(map((response: Response) => {
|
||||||
return response.json();
|
return response;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ export class OrdersService {
|
|||||||
let url = this.ordersUrl + '/api/v1/o/orders';
|
let url = this.ordersUrl + '/api/v1/o/orders';
|
||||||
|
|
||||||
return this.service.get(url).pipe(map((response: Response) => {
|
return this.service.get(url).pipe(map((response: Response) => {
|
||||||
return response.json();
|
return response;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ export class OrdersService {
|
|||||||
let url = this.ordersUrl + '/api/v1/o/orders/' + id;
|
let url = this.ordersUrl + '/api/v1/o/orders/' + id;
|
||||||
|
|
||||||
return this.service.get(url).pipe(map((response: Response) => {
|
return this.service.get(url).pipe(map((response: Response) => {
|
||||||
return response.json();
|
return response;
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Http, Response, RequestOptionsArgs, RequestMethod, Headers } from '@angular/http';
|
import { HttpClient, HttpHeaders, HttpErrorResponse } from "@angular/common/http";
|
||||||
import { IConfiguration } from '../models/configuration.model';
|
import { IConfiguration } from '../models/configuration.model';
|
||||||
import { StorageService } from './storage.service';
|
import { StorageService } from './storage.service';
|
||||||
|
|
||||||
@ -13,14 +13,14 @@ export class ConfigurationService {
|
|||||||
settingsLoaded$ = this.settingsLoadedSource.asObservable();
|
settingsLoaded$ = this.settingsLoadedSource.asObservable();
|
||||||
isReady: boolean = false;
|
isReady: boolean = false;
|
||||||
|
|
||||||
constructor(private http: Http, private storageService: StorageService) { }
|
constructor(private http: HttpClient, private storageService: StorageService) { }
|
||||||
|
|
||||||
load() {
|
load() {
|
||||||
const baseURI = document.baseURI.endsWith('/') ? document.baseURI : `${document.baseURI}/`;
|
const baseURI = document.baseURI.endsWith('/') ? document.baseURI : `${document.baseURI}/`;
|
||||||
let url = `${baseURI}Home/Configuration`;
|
let url = `${baseURI}Home/Configuration`;
|
||||||
this.http.get(url).subscribe((response: Response) => {
|
this.http.get(url).subscribe((response) => {
|
||||||
console.log('server settings loaded');
|
console.log('server settings loaded');
|
||||||
this.serverSettings = response.json();
|
this.serverSettings = response as IConfiguration;
|
||||||
console.log(this.serverSettings);
|
console.log(this.serverSettings);
|
||||||
this.storageService.store('identityUrl', this.serverSettings.identityUrl);
|
this.storageService.store('identityUrl', this.serverSettings.identityUrl);
|
||||||
this.storageService.store('marketingUrl', this.serverSettings.marketingUrl);
|
this.storageService.store('marketingUrl', this.serverSettings.marketingUrl);
|
||||||
|
@ -14,13 +14,9 @@ export class DataService {
|
|||||||
constructor(private http: HttpClient, private securityService: SecurityService) { }
|
constructor(private http: HttpClient, private securityService: SecurityService) { }
|
||||||
|
|
||||||
get(url: string, params?: any): Observable<Response> {
|
get(url: string, params?: any): Observable<Response> {
|
||||||
let options = {};
|
let options = { };
|
||||||
|
this.setHeaders(options);
|
||||||
if (this.securityService) {
|
|
||||||
options["headers"] = new HttpHeaders();
|
|
||||||
options["headers"].append('Authorization', 'Bearer ' + this.securityService.GetToken());
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.http.get(url, options)
|
return this.http.get(url, options)
|
||||||
.pipe(
|
.pipe(
|
||||||
// retry(3), // retry a failed request up to 3 times
|
// retry(3), // retry a failed request up to 3 times
|
||||||
@ -44,16 +40,8 @@ export class DataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private doPost(url: string, data: any, needId: boolean, params?: any): Observable<Response> {
|
private doPost(url: string, data: any, needId: boolean, params?: any): Observable<Response> {
|
||||||
let options = {};
|
let options = { };
|
||||||
|
this.setHeaders(options, needId);
|
||||||
options["headers"] = new HttpHeaders();
|
|
||||||
if (this.securityService) {
|
|
||||||
options["headers"].append('Authorization', 'Bearer ' + this.securityService.GetToken());
|
|
||||||
}
|
|
||||||
if (needId) {
|
|
||||||
let guid = Guid.newGuid();
|
|
||||||
options["headers"].append('x-requestid', guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.http.post(url, data, options)
|
return this.http.post(url, data, options)
|
||||||
.pipe(
|
.pipe(
|
||||||
@ -63,35 +51,10 @@ export class DataService {
|
|||||||
catchError(this.handleError)
|
catchError(this.handleError)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private doPut(url: string, data: any, needId: boolean, params?: any): Observable<Response> {
|
|
||||||
let options = {};
|
|
||||||
|
|
||||||
options["headers"] = new HttpHeaders();
|
|
||||||
if (this.securityService) {
|
|
||||||
options["headers"].append('Authorization', 'Bearer ' + this.securityService.GetToken());
|
|
||||||
}
|
|
||||||
if (needId) {
|
|
||||||
let guid = Guid.newGuid();
|
|
||||||
options["headers"].append('x-requestid', guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.http.put(url, data, options)
|
|
||||||
.pipe(
|
|
||||||
map((res: Response) => {
|
|
||||||
return res;
|
|
||||||
}),
|
|
||||||
catchError(this.handleError)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(url: string, params?: any) {
|
delete(url: string, params?: any) {
|
||||||
let options = {};
|
let options = { };
|
||||||
|
this.setHeaders(options);
|
||||||
if (this.securityService) {
|
|
||||||
options["headers"] = new HttpHeaders();
|
|
||||||
options["headers"].append('Authorization', 'Bearer ' + this.securityService.GetToken());
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('data.service deleting');
|
console.log('data.service deleting');
|
||||||
|
|
||||||
@ -103,17 +66,42 @@ export class DataService {
|
|||||||
private handleError(error: any) {
|
private handleError(error: any) {
|
||||||
if (error.error instanceof ErrorEvent) {
|
if (error.error instanceof ErrorEvent) {
|
||||||
// A client-side or network error occurred. Handle it accordingly.
|
// A client-side or network error occurred. Handle it accordingly.
|
||||||
console.error('Client side network error occurred:', error.message);
|
console.error('Client side network error occurred:', error.error.message);
|
||||||
} else {
|
} else {
|
||||||
// The backend returned an unsuccessful response code.
|
// The backend returned an unsuccessful response code.
|
||||||
// The response body may contain clues as to what went wrong,
|
// The response body may contain clues as to what went wrong,
|
||||||
console.error('Backend - ' +
|
console.error('Backend - ' +
|
||||||
`status: ${error.status}, ` +
|
`status: ${error.status}, ` +
|
||||||
`statusText: ${error.statusText}, ` +
|
`statusText: ${error.statusText}, ` +
|
||||||
`message: ${error.message}`);
|
`message: ${error.error.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return an observable with a user-facing error message
|
// return an observable with a user-facing error message
|
||||||
return throwError(error || 'server error');
|
return throwError(error || 'server error');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private doPut(url: string, data: any, needId: boolean, params?: any): Observable<Response> {
|
||||||
|
let options = { };
|
||||||
|
this.setHeaders(options, needId);
|
||||||
|
|
||||||
|
return this.http.put(url, data, options)
|
||||||
|
.pipe(
|
||||||
|
map((res: Response) => {
|
||||||
|
return res;
|
||||||
|
}),
|
||||||
|
catchError(this.handleError)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private setHeaders(options: any, needId?: boolean){
|
||||||
|
if (needId && this.securityService) {
|
||||||
|
options["headers"] = new HttpHeaders()
|
||||||
|
.append('authorization', 'Bearer ' + this.securityService.GetToken())
|
||||||
|
.append('x-requestid', Guid.newGuid());
|
||||||
|
}
|
||||||
|
else if (this.securityService) {
|
||||||
|
options["headers"] = new HttpHeaders()
|
||||||
|
.append('authorization', 'Bearer ' + this.securityService.GetToken());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,9 +175,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ProjectExtensions>
|
<ProjectExtensions>
|
||||||
<VisualStudio>
|
<VisualStudio><UserProperties package-lock_1json__JSONSchema="http://json.schemastore.org/bower" package_1json__JSONSchema="http://json.schemastore.org/project-1.0.0-beta4" /></VisualStudio>
|
||||||
<UserProperties package-lock_1json__JSONSchema="http://json.schemastore.org/bower" />
|
|
||||||
</VisualStudio>
|
|
||||||
</ProjectExtensions>
|
</ProjectExtensions>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
28
src/Web/WebSPA/package-lock.json
generated
28
src/Web/WebSPA/package-lock.json
generated
@ -3877,13 +3877,11 @@
|
|||||||
},
|
},
|
||||||
"balanced-match": {
|
"balanced-match": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"brace-expansion": {
|
"brace-expansion": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
@ -3896,18 +3894,15 @@
|
|||||||
},
|
},
|
||||||
"code-point-at": {
|
"code-point-at": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"concat-map": {
|
"concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"console-control-strings": {
|
"console-control-strings": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"core-util-is": {
|
"core-util-is": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
@ -4010,8 +4005,7 @@
|
|||||||
},
|
},
|
||||||
"inherits": {
|
"inherits": {
|
||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"ini": {
|
"ini": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
@ -4021,7 +4015,6 @@
|
|||||||
"is-fullwidth-code-point": {
|
"is-fullwidth-code-point": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"number-is-nan": "^1.0.0"
|
"number-is-nan": "^1.0.0"
|
||||||
}
|
}
|
||||||
@ -4034,20 +4027,17 @@
|
|||||||
"minimatch": {
|
"minimatch": {
|
||||||
"version": "3.0.4",
|
"version": "3.0.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"minimist": {
|
"minimist": {
|
||||||
"version": "0.0.8",
|
"version": "0.0.8",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"minipass": {
|
"minipass": {
|
||||||
"version": "2.2.4",
|
"version": "2.2.4",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"safe-buffer": "^5.1.1",
|
"safe-buffer": "^5.1.1",
|
||||||
"yallist": "^3.0.0"
|
"yallist": "^3.0.0"
|
||||||
@ -4064,7 +4054,6 @@
|
|||||||
"mkdirp": {
|
"mkdirp": {
|
||||||
"version": "0.5.1",
|
"version": "0.5.1",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"minimist": "0.0.8"
|
"minimist": "0.0.8"
|
||||||
}
|
}
|
||||||
@ -4137,8 +4126,7 @@
|
|||||||
},
|
},
|
||||||
"number-is-nan": {
|
"number-is-nan": {
|
||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"bundled": true,
|
"bundled": true
|
||||||
"optional": true
|
|
||||||
},
|
},
|
||||||
"object-assign": {
|
"object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
@ -4148,7 +4136,6 @@
|
|||||||
"once": {
|
"once": {
|
||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
}
|
}
|
||||||
@ -4254,7 +4241,6 @@
|
|||||||
"string-width": {
|
"string-width": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"bundled": true,
|
"bundled": true,
|
||||||
"optional": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"code-point-at": "^1.0.0",
|
"code-point-at": "^1.0.0",
|
||||||
"is-fullwidth-code-point": "^1.0.0",
|
"is-fullwidth-code-point": "^1.0.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user