0
I want to pass object array(in JS) to server side/ backend. Help me.
I have to read record of multiple person from the user in my web page. To mange record, i created a class Person { name, address}. And a array of Person objects, each object have different person's name and address. Now at the end i want to send this object array to server side to save data in database. So how can i ??? Note: i can't use form submission way, because i have multiple Person's records. My project: https://code.sololearn.com/WlJ2gup2mial/?ref=app
1 Réponse
+ 2
You can send it as JSON object. You can not use HTML <form> for this. You need ajax request.
Change the Content-Type of the request to application/json and POST the entire array to the backend in a single request.
fetch('/backend/endpoint/url', {
headers: {
'Content-Type': 'application/json',
},
body: entryList,
});