title: Angular typescript handling post request data
body: <p>I've created a basic function in my component TS file to make a post request to retrieve data from a server. This function works fine but when I try to place the array of data into a variable so I can then write it on page via HTML, I can't seem to get the desired effect. It seems as if I'm doing something wrong which is causing the data not to be written into the &quot;json&quot; variable.</p>
  <p>Here is my component TS, the variable I'm trying to pass the data through to is 'json';</p>
  <pre><code>  postData = {
      command: 'get_feature',
      classes: 'F,G',
    }
    
    url = &quot;http://c****************&quot;
  
    json;
  
    constructor(private http: HttpClient) {
      this.http.post(this.url, this.postData).toPromise().then((data:any) =&gt; {
        console.log(&quot;post request in progress&quot;)
        console.log(&quot;printing data array&quot;)
        console.log(data)
        this.json = data.json
        console.log(&quot;printing json variable&quot;)
        console.log(this.json)
        console.log(&quot;post request finished&quot;)
      });
    }
  </code></pre>
  <p>And here is the basic HTML, it should only write the type of data, because I haven't stringified the data yet but it's writing absolutely nothing as if there is nothing in the variable.</p>
  <pre><code>&lt;pre&gt;
    JSON test
  
    {{ json }}
  &lt;/pre&gt;
  
  </code></pre>