title: cannot read property message of undefined
body: <p>While trying to fetch the data from api using the angular's new httpclient, I get the error cannot read property message of undefined</p>
  
  <pre><code>// Here is my interface
  export interface IMessage {
      Messages: Messages[];
  }
  
  interface Messages {
      id: number;
      messageContent: string;
      fromUserId: string;
      toUserId: string;
      productId?: number;
      parentMessageId?: number;
      subject: string;
      styleNumber?: string;
  }
  </code></pre>
  
  <p>//The method that calls this api</p>
  
  <pre><code>getAllMessages(): Observable&lt;IMessage[]&gt; {
      this.messageRepositoryService.getAllMessages()
      .subscribe(data =&gt; {
        console.log('data is =&gt;', data[1].Messages); // here is error
        this.messages = data;
      },
      err =&gt; {
        console.log('Error occured while fetching country List');
      });
      return;
    }
  
    // in the service
  getAllMessages(): Observable&lt;IMessage[]&gt; {
          return this.http.get&lt;IMessage[]&gt;(`${this.ROOT_URL}/list`);
      }
  </code></pre>
  
  <p>To see how the response looks from the api, Here is the url <a href="http://52.70.78.117:7111/api/message/list" rel="nofollow noreferrer">http://52.70.78.117:7111/api/message/list</a></p>
  
  <p><a href="https://i.stack.imgur.com/gcKVx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gcKVx.png" alt="Here is how my object looks"></a></p>
  
  <pre><code>{"data":{"Messages":[{"Id":1,"MessageContent":"test","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":null,"Subject":"Test Message","StyleNumber":null},{"Id":2,"MessageContent":"test data","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":null,"Subject":"Test Message by Dev Team","StyleNumber":null},{"Id":3,"MessageContent":"test","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":4,"MessageContent":"test","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":5,"MessageContent":"testtesttesttest","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":6,"MessageContent":"testtesttesttest","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":7,"MessageContent":"testtesttesttest","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":8,"MessageContent":"Test","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":9,"MessageContent":"Test Message","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":10,"MessageContent":"Test Message","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":11,"MessageContent":"96b1c943-ade0-4026-b8ed-0f4a6231e58696b1c943-ade0-4026-b8ed-0f4a","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"Test Message","StyleNumber":null},{"Id":12,"MessageContent":"96b1c943-ade0-4026-b8ed-0f4a6231e586","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"96b1c943-ade0-4026-b8ed-0f4a6231e586","StyleNumber":null},{"Id":13,"MessageContent":"96b1c943-ade0-4026-b8ed-0f4a6231e586","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"96b1c943-ade0-4026-b8ed-0f4a6231e586","StyleNumber":null},{"Id":14,"MessageContent":"96b1c943-ade0-4026-b8ed-0f4a6231e586","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"96b1c943-ade0-4026-b8ed-0f4a6231e586","StyleNumber":null},{"Id":15,"MessageContent":"96b1c943-ade0-4026-b8ed-0f4a6231e586","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"96b1c943-ade0-4026-b8ed-0f4a6231e586","StyleNumber":null},{"Id":16,"MessageContent":"96b1c943-ade0-4026-b8ed-0f4a6231e586","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"96b1c943-ade0-4026-b8ed-0f4a6231e586","StyleNumber":null},{"Id":17,"MessageContent":"test","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"test","StyleNumber":null},{"Id":18,"MessageContent":"test message","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":null,"Subject":"test message","StyleNumber":null},{"Id":19,"MessageContent":"test data","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":null,"Subject":"Test Message by Dev Team","StyleNumber":null},{"Id":20,"MessageContent":"test message","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":null,"Subject":"test message","StyleNumber":null},{"Id":21,"MessageContent":"test","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"test mness","StyleNumber":null},{"Id":22,"MessageContent":"test","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"test ","StyleNumber":null},{"Id":25,"MessageContent":"test message","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":1,"Subject":"test message","StyleNumber":null},{"Id":28,"MessageContent":"test data tsn","FromUserId":"74df8f98-2925-4242-8d32-8b09f3691396","UserName":"365@test.com","ToUserId":"96b1c943-ade0-4026-b8ed-0f4a6231e586","ProductId":null,"ParentMessageId":null,"Subject":"Test Message by Dev Team","StyleNumber":null}],"Pagination":{"Page":1,"PageLength":20,"TotalRecords":20,"TotalPages":1},"MessageLimit":{"TotalMessageCount":5,"RemainingMessageCount":3}}}
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/FjGwm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FjGwm.png" alt="enter image description here"></a></p>