TypeError: formdata.set is not a function


#1

Hello All,
I’m using FormData for one of my ajax call in Ionic.
var formdata = new FormData();
formdata.set(‘action’, “myActionName”);
formdata.set(‘senderId’, data.senderId);
formdata.set(‘friendId’, data.friendId);

its working perfectly okay on Android but on iOS it says:
TypeError: formdata.set is not a function. (In ‘formdata.set(‘action’, “myActionName”)’, ‘formdata.set’ is undefined)

Anyone know how to define the formdata.set?

Thanks in Advance!


#2

@charlestsmith I have the same issue on a few android devices. Did you find a solution?


#3

Hey, so the solution is to avoid set (and get, getAll etc). If you log the FormData object for failing devices, you can see it has only the append method. Check out this SO answer