Skip to content

Commit

Permalink
Convert null value from postObservation form to empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrucs committed Jul 3, 2024
1 parent 3600e80 commit 56962f4
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/api/postObservation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ async function postObservation(
const body = new FormData();

Object.entries(props).forEach(([key, value]) => {
body.append(key, value);
// `null` in formData is converted to `'null'`
// We convert them to an empty string to avoid it
const nextValue = value !== null ? value : '';
body.append(key, nextValue);
});

Array.from({ length: 5 }).forEach((_, index) => {
Expand Down

0 comments on commit 56962f4

Please sign in to comment.