Forum Discussion

GeorgeTio's avatar
GeorgeTio
New Member
3 years ago

React file upload

Hello is there any possible way I can upload a file using react, I currently have the following source code

 

 fetch(
          {
            headers: {
              Authorization:
                "Bearer " + token,
              "Content-Type": "multipart/form-data",
             
            },
            method: "POST",
            body: formData,
          }
        )
          .then(
            (response) => response.json() // if the response is a JSON object
          )
          .then(
            (success) => console.log("success", success) // Handle the success response object
          )
          .catch(
            (error) => console.log("error", error) // Handle the error response object
          );
 
when I try to upload a file i am getting error response code that body is missing
No RepliesBe the first to reply