Use fetch to upload formdata files

Use fetch to upload formdata files

Don't set content-type randomly when uploading formdata files with fetch

      let opts = {
    
    
        method: "POST",
        body: formData,
        headers: {
    
    
    		 // Content-Type:'application/x-www-form-urlencoded'不要随便设置
        },
      };

      let url = "http://localhost:3000/upload";
      fetch(url, opts)
        .then((res) => res.text())
        .then((data) => console.log(data));
        

Do not follow the Baidu "fetch" + "formdata" keyword in the first article to set the content of this article to be miserable/(ㄒoㄒ)/~~

Guess you like

Origin blog.csdn.net/anothercx/article/details/111937943