title: How to pass an object containing array of object as parmters to API
body: <p>I am having error with posting nested object array as parameter to API which returns Internal Server 500 error.</p>
  
  <pre><code> let data= {
     id:'1',
     customerId:cid,
     list:list
    };  
  </code></pre>
  
  <p>where <code>list</code> is array of objects</p>
  
  <pre><code>list = [{a:1,b:1},{a:2,b:2},{a:3,b:3}];
  </code></pre>
  
  <p>I have tried converting them to url parameters like</p>
  
  <pre><code>var cstr = JSON.stringify(list);
  var clist = cstr.replace(/\"([^(\")"]+)\":/g,"$1:");
  let urlParameters = Object.entries(data).map(e =&gt; encodeURIComponent(e[0])+"="+encodeURIComponent(e[1])).join('&amp;');
  </code></pre>
  
  <p>but I'm recieving <code>Internal Server Error 500</code> in console.</p>
  
  <p>and my api request code is</p>
  
  <pre><code>fetch(url, {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/x-www-form-urlencoded',
            'x-auth-token': token,
        },
        body: urlParameters
        }).then((response) =&gt; {
          console.log(response);
              return response.json();
        }).then((responseJson) =&gt; {
            console.log(responseJson);
        }).catch((error) =&gt; {
          console.error(error);
        });
  
      };
  </code></pre>