The JSON object is converted into a formdata object, and the formdata object is converted into a JSON object

in the backward request, if there is a file object in the uploaded data, we need to use the form submission, at this time we need to convert the JSON object into a formData object, see the code

for details

  const formData = new FormData();
  Object.keys(params).forEach((key) => {
    formData.append(key, params[key]);
  });

may also require formData to be converted to JSON, the code is as follows:

  var jsonData = {};
  formData.forEach((value, key) => jsonData[key] = value);

Read More: