Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- currentUse(SVF){
- //let options = {headers: new HttpHeaders({'Content-Type': 'application/json'})};
- const httpOptions = {
- headers: new HttpHeaders({
- 'Content-Type': 'application/json'
- //'Access-Control-Allow-Origin':
- })
- };
- httpOptions.headers.set('Access-Control-Allow-Origin','http://axis2.icd.teradyne.com:8080');
- return this.http.post<any>('http://axis2.icd.teradyne.com:8080/test', SVF, httpOptions)
- .pipe(catchError(this.handleError))
- }
- Access-Control-Allow-Origin →*
- Content-Length →4
- Content-Type →text/html; charset=utf-8
- Date →Wed, 22 Aug 2018 01:09:10 GMT
- Server →Werkzeug/0.14.1 Python/3.6.2
- import { Injectable } from '@angular/core';
- import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
- import { Observable } from 'rxjs';
- @Injectable({ providedIn: 'root' })
- export class HeaderInterceptor implements HttpInterceptor {
- intercept(req: HttpRequest<any>, next: HttpHandler):
- Observable<HttpEvent<any>> {
- req = req.clone({ headers: req.headers.set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8') });
- return next.handle(req);
- }
- }
- import { HttpClientModule, HttpClient, HTTP_INTERCEPTORS } from '@angular/common/http';
- { provide: HTTP_INTERCEPTORS, useClass: HeaderInterceptor, multi: true }
Add Comment
Please, Sign In to add comment