0
1.私はuseCredentials.Canの誰かがコードに間違っていることを教えてもらえますか?資格情報付きのHttp投稿。何が間違っているのですか?
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オブジェクト - ここに問題があると思います。
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;});
}
}
ああ。ありがとうございます。もし私がボディパラムを送る必要がないのであれば? withCredentials:trueの部分についてはどうですか?正しいの? – Serhiy
@Serhiyはその件についてこの投稿をチェックします。http://stackoverflow.com/q/35007572/5706293 – echonax
cool。あなたの助言が働く。私は体を見逃してしまった、私は角度1で私は体のないこの要求をこのように送った。そして、私は問題が何かを見つけることができませんでした。あなたは私をたくさん助けました。ありがとうございました!!! – Serhiy