title: Fetch Api get params
body: <p>I am trying to make a "GET" request using window.fetch, and I need to pass in a param which takes in an entire array as the value. For example, the request url should look like this</p>
  
  <pre><code>'https://someapi/production?moves=[]'
  </code></pre>
  
  <p>I have the following segment, which ends up in a 400 request, because the array gets evaluated to empty</p>
  
  <pre><code>let url = new URL('https://someapi/production');
  let params = {moves: []};
  Object.keys(params).forEach(key =&gt; url.searchParams.append(key, params[key]));
  console.log(url);
  fetch(url.href)
      .then(res =&gt; res.json())
      .then(val =&gt; {
            console.log(val);
       });
  </code></pre>
  
  <p>Upon inspecting the url.href looks like</p>
  
  <pre><code>https://someapi/production?moves=
  </code></pre>
  
  <p>where as I want it to be </p>
  
  <pre><code>https://someapi/production?moves=[]
  </code></pre>
  
  <p>Any suggestions on how I can achieve this?</p>