Twilio聊天令牌发行

时间:2020-10-05 15:44:28

标签: twilio chat

我正在将Twilio Chat集成到我的Web应用程序中, 但是,当我传递服务器生成的访问令牌时, 它显示此错误。

enter image description here

我的代码段如下:

fetch(
      URL,
      {
        headers: { "Content-Type": "application/x-www-form-urlencoded" },
        method: "POST",
        body: `identity=${encodeURIComponent(username)}`,
      }
    )
      .then((res) => res.json())
      .then(({ token }) => {
        Chat.Client.create(token)
          .then((client) => {
            setupChatClient(client);
          })
          .catch(handleError);
      })
      .catch(handleError);

调用函数时,我确实传递了username作为身份,API确实返回了令牌,但我只是不知道为什么它不高兴:(

0 个答案:

没有答案