Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FormData boolean field?

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.

like image 634
Oblivion Avatar asked Mar 05 '23 02:03

Oblivion


1 Answers

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

like image 157
front_end_dev Avatar answered Mar 16 '23 15:03

front_end_dev