mam wysłać dane pod adres gdzie struktura wygląda tak: (Name,X,Y,RouteId,Description pobieram z formularza). Niestety zwraca mi null i nic nie wysyła..
"PointList": {
[{
"Name": Name,
"Y": Y,
"X": X,
"RouteId": RouteId,
"Description": Description,
}]
}
najpierw dodaje sobie taka strukture do tablicy
appendElement = (Name, Description, X, Y, RouteId) => {
this.setState({
elements: ([...this.state.elements, {
"PointList": ([{
"Name": Name,
"Y": Y,
"X": X,
"RouteId": RouteId,
"Description": Description,
}])
}]),
})
i np mam jak mam 3 obiekty w elements to po kliknieciu utworz:
handleOnHistoryPush = (e) => {
fetch("http://dearjean.ddns.net:44301/api/Add", {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ ...this.state.elements })
})
.then(res => res.json())
.then(res => {
console.log(res);
})
this.setState({ elements: ([]) });
};