用户电子邮件在twilio聊天Web应用程序中显示为空

时间:2018-08-12 05:16:12

标签: angular typescript angular6 twilio-api

我正在使用Twilio API(在angular中使用)聊天应用。消息正在正确发送,但在某些消息中,messages.from(email)显示NULL

TypeScript代码

//View all messages
// name = localStorage.getItem('name');

allMessages=[];
totalMessages: number;

viewMessage() {

// console.log(this.name + "viewName");

   this.chatBox.viewMessages().subscribe(res => {
   this.allMessages = res.messages ;

//adding user email address to messages

   this.allMessages.forEach(element => {
       element.body+=('('+element.from+')')
   });
  console.log(this.allMessages)
 },
 err => {
   console.log(err);
 })

}

以下是我的服务代码

sendMessage(messages):Observable<any>{
  return 
  this.http.post("https://chat.twilio.com/v2/Services/"
  + this.serviceId + "/Channels/" + this.myChannelId + "/Messages", 
  "ChannelSid=" + this.myChannelId + "&ServiceSid=" + this.serviceId +
  "&Body=" + messages + "&From=" + this.identity,this.httpOpt); 
}

这是我的html代码

<section class="timeline">
   <ul >
      <li *ngFor="let message of allMessages">
        <div>
           {{message.body}}
        </div>
      </li>            
        <!-- more list items here -->
   </ul>
</section>

0 个答案:

没有答案