javascript - 从 Node.js 订阅 SalesForce 主题时出错
问题描述
我正在尝试使用JSForce 文档中提供的代码从 Node.js 服务器订阅 SalesForce 主题:
conn.streaming.topic("InvoiceStatementUpdates").subscribe(function(message) {
console.log('Event Type : ' + message.event.type);
console.log('Event Created : ' + message.event.createdDate);
console.log('Object Id : ' + message.sobject.Id);
});
但是,我收到一个错误location is not defined
[1552904103100] ERROR (13143 on myuser): location is not defined
ReferenceError: location is not defined
at Object.parse (/home/myuser/projects/my-project/node_modules/faye/src/util/uri.js:36:36)
at klass.initialize (/home/myuser/projects/my-project/node_modules/faye/src/protocol/dispatcher.js:21:28)
at klass (/home/myuser/projects/my-project/node_modules/faye/src/util/class.js:13:28)
at Function.Dispatcher.create (/home/myuser/projects/my-project/node_modules/faye/src/protocol/dispatcher.js:179:10)
at klass.initialize (/home/myuser/projects/my-project/node_modules/faye/src/protocol/client.js:44:35)
at klass (/home/myuser/projects/my-project/node_modules/faye/src/util/class.js:13:28)
at Streaming._createClient (/home/myuser/projects/my-project/node_modules/jsforce/lib/api/streaming.js:127:20)
at Streaming._getFayeClient (/home/myuser/projects/my-project/node_modules/jsforce/lib/api/streaming.js:148:42)
at Streaming.subscribe (/home/myuser/projects/my-project/node_modules/jsforce/lib/api/streaming.js:185:25)
at Topic.subscribe (/home/myuser/projects/my-project/node_modules/jsforce/lib/api/streaming.js:41:26)
深入研究这个问题,我在 Github 中发现了一条评论,指出faye 是 JSForce 的直接依赖项,只能在浏览器应用程序中使用。然而,JSForce 预计可以在客户端和服务器端工作。
任何关于为什么会发生这种情况的想法都将不胜感激。谢谢!
解决方案
我终于解决了login()
在尝试该streaming
功能之前进行显式调用的问题。
推荐阅读
- macos - 适用于 macOS 的 SwiftUI 3.0:如何将 .frame 设置为以最大屏幕空间打开
- c# - 将字符串转换为 GSM
- bash - mv:无法重命名:没有这样的文件或目录。但是目录存在
- javascript - LocalStorage 数据导入MongoDB
- c# - 无需加载完整文档即可获取 PDF XMP 元数据
- python - 从嵌套字典生成边缘列表
- automated-tests - 使用 MFA 自动化测试
- angular - 在 Angular 7 鼠标悬停时填充表格列上的数据
- c - 在 VS Code 中运行 C 时修复“main”的多个定义
- selenium - 为什么 selenium webdriver 找不到元素