Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
45
rated 0 times [  50] [ 5]  / answers: 1 / hits: 15757  / 6 Years ago, thu, november 8, 2018, 12:00:00

I need to use booleans within form data. For example:



let example = new FormData();
example.append('aBoolean', true);


This throws and error as the above 'true' needs to be in string form. Do you know a way I can use booleans within FormData? Alternatively even a way to cast it as a boolean when I get the value by:



example.get(aBoolean)


Assuming i did store the true as a string in the above example.


More From » angular

 Answers
116

Well you cannot set Boolean into FormData append method. Only allow datatype are USVString,Blob.



Read more about it from mdn documentation



https://developer.mozilla.org/en-US/docs/Web/API/FormData/append



https://developer.mozilla.org/en-US/docs/Web/API/USVString


[#53150] Sunday, November 4, 2018, 6 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kristopher

Total Points: 58
Total Questions: 103
Total Answers: 102

Location: Netherlands
Member since Thu, Jul 1, 2021
3 Years ago
;