Guest User

Untitled

a guest
Aug 22nd, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. currentUse(SVF){
  2. //let options = {headers: new HttpHeaders({'Content-Type': 'application/json'})};
  3. const httpOptions = {
  4. headers: new HttpHeaders({
  5. 'Content-Type': 'application/json'
  6. //'Access-Control-Allow-Origin':
  7. })
  8. };
  9. httpOptions.headers.set('Access-Control-Allow-Origin','http://axis2.icd.teradyne.com:8080');
  10.  
  11. return this.http.post<any>('http://axis2.icd.teradyne.com:8080/test', SVF, httpOptions)
  12. .pipe(catchError(this.handleError))
  13. }
  14.  
  15. Access-Control-Allow-Origin →*
  16. Content-Length →4
  17. Content-Type →text/html; charset=utf-8
  18. Date →Wed, 22 Aug 2018 01:09:10 GMT
  19. Server →Werkzeug/0.14.1 Python/3.6.2
  20.  
  21. import { Injectable } from '@angular/core';
  22. import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
  23.  
  24. import { Observable } from 'rxjs';
  25.  
  26.  
  27. @Injectable({ providedIn: 'root' })
  28. export class HeaderInterceptor implements HttpInterceptor {
  29.  
  30. intercept(req: HttpRequest<any>, next: HttpHandler):
  31. Observable<HttpEvent<any>> {
  32. req = req.clone({ headers: req.headers.set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8') });
  33. return next.handle(req);
  34. }
  35. }
  36.  
  37. import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
  38.  
  39. { provide: HTTP_INTERCEPTORS, useClass: HeaderInterceptor, multi: true }
Add Comment
Please, Sign In to add comment