How to inspect FormData?

前端 未结 15 1524
悲&欢浪女
悲&欢浪女 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条回答
  •  误落风尘
    2020-11-22 08:46

    When I am working on Angular 5+ (with TypeScript 2.4.2), I tried as follows and it works except a static checking error but also for(var pair of formData.entries()) is not working.

    formData.forEach((value,key) => {
          console.log(key+" "+value)
    });
    

    var formData = new FormData();
    formData.append('key1', 'value1');
    formData.append('key2', 'value2');
    
    formData.forEach((value,key) => {
      console.log(key+" "+value)
    });

    Check at Stackblitz

提交回复
热议问题