[VOTE] fix payload in the absence of a token

pull/73/head
Pierre-Louis Guhur 4 years ago committed by guhur
parent b8abc01cdb
commit f068b7a9e1

@ -149,14 +149,18 @@ class Vote extends Component {
gradesByCandidate.push(gradesById[id]); gradesByCandidate.push(gradesById[id]);
}); });
const payload = {
election: electionSlug,
grades_by_candidate: gradesByCandidate,
}
if (token !== ""){
payload["token"] = token;
}
fetch(endpoint, { fetch(endpoint, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
body: JSON.stringify({ body: JSON.stringify(payload)
election: electionSlug,
grades_by_candidate: gradesByCandidate,
token: token,
})
}) })
.then(this.handleErrors) .then(this.handleErrors)
.then(result => .then(result =>

Loading…
Cancel
Save