0

This seems like something with a really easy fix, but I can't figure it out. I have the following in the Google Developer console:

var formData = new FormData();
formData.append("a", "b")
console.log(formData)
FormData {}

Why is the FormData object still empty even after adding a key and value to it?

Alex
  • 3,946
  • 11
  • 38
  • 66
  • because that's not how you get the key pairs stored in a FormData. You'll want either `formData.get('a')`, or `formData.getAll('a')` or if you don't know the keys `f.forEach((val, key)=>console.log(val, key))` – Kaiido Feb 17 '17 at 05:03
  • let formData = new FormData(); After this, the only method that formData has is append(). Property 'get' does not exist on type 'FormData' .) This also happens with entries() and everything. Any idea? – Gaston K Feb 17 '17 at 09:06
  • @GastonK, which browser ? Only FF and chrome support these methods. For IE and Safari, there is no way to get it... But IMO, it should only be used for debugging, for developpement, you should know when you do append to your formData, or even from which `
    ` it has been created, so you always have a way to know what is in there.
    – Kaiido Feb 17 '17 at 11:39
  • chrome. When doing console log doesnt work, but from the dev tools it does. strange. – Gaston K Feb 17 '17 at 11:51

0 Answers0