Last active
August 25, 2021 09:55
-
-
Save agentgill/0f61af702f9b3af5311910e53e92a3a3 to your computer and use it in GitHub Desktop.
Subscriber to Platform Event using JSForce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var jsforce = require("jsforce"); | |
| require("dotenv").config(); | |
| var username = process.env.SFDC_USER; | |
| var password = process.env.SFDC_PWD; | |
| var conn = new jsforce.Connection({ loginUrl: "https://login.salesforce.com" }); | |
| conn.login(username, password, function (err, userInfo) { | |
| const replayId = 13475880; | |
| const replayExt = new jsforce.StreamingExtension.Replay( | |
| process.env.EVENT_TYPE, | |
| replayId | |
| ); | |
| const fayeClient = conn.streaming.createClient([replayExt]); | |
| if (err) { | |
| return console.log(err); | |
| } | |
| console.log("Connected to" + process.env.EVENT_TYPE); | |
| const subscription = fayeClient.subscribe( | |
| process.env.EVENT_TYPE, | |
| (data) => { | |
| console.log("topic received data", data); | |
| } | |
| ); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment