I am facing an issue while trying to make a POST request in Ionic for submitting a form with an array of data. Surprisingly, it works perfectly fine when I test it on POSTMAN.
https://i.sstatic.net/t8sEG.jpg
Although I attempted to use this form, it did not yield the desired results:
submitRegistration(value):void{
var headers = new Headers();
let options = new RequestOptions({headers: headers});
headers.append("Content-Type", 'application/json');
let link = 'http://apidata.com/';
let myData = {
fos_user_registration_form: [{
_token: this.data.token,
username: value.usuario,
email: value.correo,
plainPassword: [{
first: value.password,
second: value.confirmPassword
}],
userLocalization: value.municipio}
]};
console.log(myData);
this.http.post(link, myData, options)
.subscribe(data => {
this.data.response = data["_body"];
}, error => {
alert("Oooops!");
});
}
Could someone kindly provide assistance?