title: How to properly implement wrapper around http.get in typescript?
body: <p>First of all, my Typescript knowledge is very low, so I assume that this is a somewhat basic question. In the frontend of my web application, there are two parameters which I need to provide in 99% of all http get-requests. To make my life a little bit easier, I decided to write a simple wrapper around <code>HttpClient</code> (from &quot;@angular/common/http&quot;) which provides these params for me. All I need to pass to it is an object from which it then reads those two parameters and adds them to the parameters of the get-request. Here is how this code currently looks like:</p>
  <pre><code>public get&lt;T&gt;(url: string, additionalObj?: AdditionalObject) {
    if (additionalObj == null) {
      return this.http.get&lt;T&gt;(url, {
        headers: {
          &quot;Content-Type&quot;: &quot;application/json&quot;,
        },
      });
    } else {
      const params: Record&lt;string, string&gt; = {};
      const param1: string | undefined = additionalObj?.param1;
      const param2: string | undefined = additionalObj?.param2;
  
      if (param1) {
        params[&quot;param1&quot;] = param1;
      }
      if (param2) {
        params[&quot;param2&quot;] = param2;
      }
  
      return this.http.get&lt;T&gt;(url, {
        headers: {
          &quot;Content-Type&quot;: &quot;application/json&quot;,
        },
        params,
      });
    }
  }
  </code></pre>
  <p>While this works just fine in most cases, I also have some functions which need to provide even more params to the get-request, so I need some way to merge the params provided to my function with the two params which I provide inside the function, but I don't know how to do that. I do not want to change anything in the functions which already call my function but I also want to provide a way to specify additional params if necessary. How can I do that?</p>