1
私は以下の角2でhttpのポストを作ろうとしています。 HTTPポストはjsonオブジェクトの周りに引用符を追加するので、呼び出しは失敗します。リクエストから引用符を削除するにはどうすればよいですか?以下角2のHTTPポストはjsonオブジェクトの周りに引用符を追加します
export class Compentency {
competencies : number[];
}
postData() {
let array = [1, 2, 3, 6];
this.comp.competencies = array;
let headers = new Headers({ 'Content-Type': 'application/x-www-form-urlencoded' });
let options = new RequestOptions({ headers: headers, method: 'post' });
return this.http.post(this.postUrl, this.comp, options)
.map(res => res.json().data.competencies)
.catch(this.handleError);
}
サーバー
{
"competencies": [ 1, 2, 3, 6 ]
}:
私はデータを文字列化しました。これはフォームデータ{"competencies":[1,2,3,6]}の周りに引用符を追加します:私のサーバーはキーの引用符を受け付けません。 – Manohar