Last active
March 28, 2018 23:31
-
-
Save ajb413/48a3e8310d2c2ec91a4ca6f2287cb7aa to your computer and use it in GitHub Desktop.
Sample PubNub Function
This file contains 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
// PubNub Functions event handler | |
// Deploy globally in minutes at https://admin.pubnub.com/ | |
// Specify one channel or all with '*' in the editor | |
// Use `xhr.fetch(url).then()` to do an HTTP request | |
const xhr = require("xhr"); | |
export default (request) => { | |
// Replaces all instances of "bad" with "good" while a message is in transit | |
request.message.text.replace(/bad/g, "good"); | |
return request.ok(); // Return a promise when you're done | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment