Categories
JavaScript Answers

How to debug FormData.append(“key”, “value”) is not working with JavaScript?

Spread the love

Sometimes, we want to debug FormData.append("key", "value") is not working with JavaScript.

In this article, we’ll look at how to debug FormData.append("key", "value") is not working with JavaScript.

How to debug FormData.append("key", "value") is not working with JavaScript?

To debug FormData.append("key", "value") is not working with JavaScript, we can loop through the values with a loop.

For instance, we write

for (const data of formData) {
  console.log(data);
}

to loop through the entries of the formData FormData object with a for-of loop.

In it, we log the data value.

This works because a FormData object is an iterable object.

Conclusion

To debug FormData.append("key", "value") is not working with JavaScript, we can loop through the values with a loop.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *