How to inspect FormData?

前端 未结 15 1349
悲&欢浪女
悲&欢浪女 2020-11-22 08:23

I\'ve tried console.log and looping through it using for in.

Here it the MDN Reference on FormData.

Both attempts are in this fi

15条回答
  •  -上瘾入骨i
    2020-11-22 08:31

    Try this function:

    function formDataToObject(formData) {
      return Array.from(formData.entries()).reduce((old, pair) => ({
        ...old,
        [pair[0]]: pair[1],
      }), {});
    }
    

提交回复
热议问题