title: How to create a JSON Object's element based on if it is null or not?
body: <pre><code>     async homeApi(_source: any, _args: any) {
          const body = {
            door: _args.door,
            window: _args.window
          };
  }
  </code></pre>
  
  <p>I have a typescript code like above where I create a JSON Object called <code>body</code> using <code>door</code> and <code>window</code> arguments.
  Typically the body should be:</p>
  
  <pre><code>     {
      door: 3,
      window: 4
     }
  </code></pre>
  
  <p>What I want is if <code>_args.door</code> is empty/blank, the <code>body</code> should be </p>
  
  <pre><code>{window: 4}
  </code></pre>
  
  <p>It should not be: </p>
  
  <pre><code>{
      door: '',
      window: 4
  }
  </code></pre>