title: How to pass array to formdata and save as array in react.js
body: <p>i am passing an array to formdata but getting it as string.
  How can i save it in array only.</p>
  <pre><code>tags=[&quot;abc&quot;, &quot;def&quot;, &quot;ghi&quot;]
  formData.set(&quot;tags&quot;,tags);
  
  </code></pre>
  <p>if i do this at frontend then nothing is getting save at backend</p>
  <pre><code>const clickSubmit = (event) =&gt; {
      event.preventDefault();
      setValues({ ...values, error: &quot;&quot;, loading: true });
      tags.forEach((tag) =&gt; formData.append(&quot;tags[]&quot;, tag));
      createProduct(formData).then((data) =&gt; {
        if (data.error) {
          setValues({ ...values, error: data.error });
        } else {
          setValues({
            ...values,
            name: &quot;&quot;,
            description: &quot;&quot;,
          });
        }
      });
    };
  </code></pre>
  <p>the backend code after submitting form</p>
  <pre><code>exports.create = (req, res) =&gt; {
    console.log(&quot;REQ&quot;, req.body);
    let form = new formidable.IncomingForm();
    form.keepExtensions = true;
    form.parse(req, (err, fields, files) =&gt; {
      if (err) {
        return res.status(400).json({
          error: &quot;Image could not be uploaded&quot;,
        });
      }
      let product = new Product(fields);
      console.log(&quot;P&quot;, product);
  
      if (files.photo) {
        product.photo.data = fs.readFileSync(files.photo.path);
        product.photo.contentType = files.photo.type;
      }
  
      product.save((err, result) =&gt; {
        if (err) {
          return res.status(400).json({
            error: errorHandler(err),
          });
        }
        res.json(result);
      });
    });
  };
  </code></pre>
  <p>also the req.body giving empty object,why so i have use</p>
  <pre><code>app.use(express.json());
  app.use(express.urlencoded({ extended: true }));
  </code></pre>