【问题标题】:Getting IP address and other connection information at Meteor Collection?在 Meteor Collection 中获取 IP 地址和其他连接信息?
【发布时间】:2016-10-27 20:11:54
【问题描述】:

我知道获取连接信息的方法是this.connection,但这适用于服务器端,这需要服务器端的上下文。 here 的一些帮助,但找不到解决方案。正如here 解释的那样,Collection 在客户端和服务器端共享,这让我很困惑如何在 Meteor-Collection 获取服务器上下文或连接信息,因为我在其中使用了一些方法。

【问题讨论】:

    标签: meteor meteor-blaze


    【解决方案1】:

    您可能希望将代码包装到 ensure it's running on the server,例如:

    if (Meteor.isServer) {
        console.log(this.connection)
    }
    

    【讨论】:

    • 即使我确保它没有给出服务器或连接属性的上下文。
    猜你喜欢
    • 1970-01-01
    • 2021-07-08
    • 1970-01-01
    • 1970-01-01
    • 2015-04-17
    • 2022-06-12
    • 2011-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多