1.I can't setup a proper request, with useCredentials.Can anyone tell me what's wrong with the code?
import { Injectable } from '@angular/core';
import { Http, Response,Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Observable';
@Injectable ()
export class StructureRequestService {
result: Object;
constructor (private http: Http) {
2.use XHR object - I think the problem is here.
let _build = (<any> http)._backend._browserXHR.build;
(<any> http)._backend._browserXHR.build = () => {
let _xhr = _build();
_xhr.withCredentials = true;
return _xhr;
};
}
private myUrl = 'http://manny.herokuapp.com/audit/get/structure';
//create an http request
sendRequest() {
let headers = new Headers({ 'Content-Type': 'application/json' });
let options = new RequestOptions({
headers: headers
// , withCredentials: true
});
return this.http.post(this.myUrl,options)
.map((res: Response) => res.json())
.subscribe(res => {this.result = res;});
}
}