Hi,
I want to store this array in sql.in name column all name data will be store.in age and gender also like this.
this.state = {
rows: [],
Name: [],
Age: [],
Gender: [],
}
- 0: {key: 0, name: 'x', age: 24, gender: 'F'}
- 1: {key: 1, name: 'x', age: 23, gender: 'F'}
- 2: {key: 2, name: 'x', age: 26, gender: 'F'}
handleSubmit = async event => {
console.log("submitting: ", this.state.rows);
let arr = this.state.Name;
let arr2 = this.state.Age;
let arr3 = this.state.Gender;
this.state.rows.forEach((i, v) => {
arr.push(i.name);
});
this.state.rows.forEach((i, v) => {
arr2.push(i.age);
});
this.state.rows.forEach((i, v) => {
arr3.push(i.gender);
});
event.preventDefault();
var body = {
Name: arr ,
Age:arr2,
Gender:arr3
};
fetch(url, {
method: 'post',
headers: {'Content-Type':'application/json'},
body: JSON.stringify(body)
});
};
this value coming from table data not from form. in c# i am using [FROMFORM] method.but this value passing null only.how can i store punch of table record to the sql from react table