Skip to content

Instantly share code, notes, and snippets.

@ajb413
Last active March 28, 2018 23:31
Show Gist options
  • Save ajb413/48a3e8310d2c2ec91a4ca6f2287cb7aa to your computer and use it in GitHub Desktop.
Save ajb413/48a3e8310d2c2ec91a4ca6f2287cb7aa to your computer and use it in GitHub Desktop.
Sample PubNub Function
// 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