I have a array like this.
myarr = [{ 'madde': '1' , 'deger': 'truea' } , { 'madde': '2', 'deger': 'falsea' }];
I want to send this array to my server
let dataitems = this.myarr.map( x => JSON.stringify(x));
const req = this.http.post( nestleapiurl + saveform , {
'listitem': dataitems.toString() ,
}, {headers: headers} )
.subscribe(
res => {
console.log(res);
},
err => {
console.log('Error occured');
console.log( 'Gönderilen:' + this.myarr.toString() );
}
);
i want to send in this format , but i couldnt do.
{
"listitem":[
{ "madde":"1" , "deger": "truea" } , { "madde": "2", "deger": "falsea" }
]
}
i can send the json below with postman app to the server, but i couldnt send it with angular js application.
how can i format my array to json ?
Thanks.
