Ask a Question

React file upload

GeorgeTio
New Member

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
0 REPLIES 0
cancel
Showing results for 
Search instead for 
Did you mean: