title: Simplifying JS query from JSON API
body: <p>I'm trying to display some data from a API, using similar to the below example.</p>
  <p>I need to feed in data such as a Video ID from a CMS, which will then retrieve additional data from the API about the video.</p>
  <p>The below example works, but I'm not sure I've written it in the best way - and I would like to be able to set a variable using a Video ID from the CMS's front end template string. Below I am having to repeat the Video ID in order to get it to work - and I'm struggling to simplify this.</p>
  <p>Any help appreciated!</p>
  <pre><code>async function getSomething() {
      let request = {
          item: {
              name: &quot;example&quot;,
              colour: &quot;red&quot;
          },
          video: [&quot;12345&quot;]
      };
      let url = new URL(&quot;https://example.com&quot;); 
      url.searchParams.append('data', JSON.stringify(request));
      let response = await fetch(url);
      let data = await response.json();
      console.log(data.video);
      return data;
  }
  
  getSomething().then(data =&gt; 
      document.querySelector('[data-video-id]').innerHTML = data.video.12345.label
  );
  </code></pre>