I am trying to convert a JavaScript object into x-www-form-urlencoded. Is there a way to achieve this using Angular 2?
export class Compentency {
competencies : number[];
}
postData() {
let array = [1, 2, 3];
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, JSON.stringify(this.comp), options)
.map(res => res.json().data.competencies)
.catch(this.handleError);
}