首页 > 解决方案 > NodeJs 到 Typescript

问题描述

我需要在我的角度项目中使用 nodejs 库,但在 nodejs 中获得了示例代码。我已经通过 npm 命令安装了库并导入到我的组件中。但它总是显示未定义。

npm install phenix-edge-auth --save

const TokenBuilder = require('phenix-edge-auth');

// Create a token to access a channel
const token = new TokenBuilder()
    .withApplicationId('my-application-id')
    .withSecret('my-secret')
    .expiresInSeconds(3600)
    .forChannel('us-northeast#my-application-id#my-channel.1345')
    .build();

如何将此代码与角度应用程序一起使用?

标签: node.jstypescript

解决方案


以角度方式导入它..

import * as TokenBuilder from 'phenix-edge-auth'

推荐阅读