Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PubNub Message Copy - https://admin.pubnub.com/#/blocks/1165/import - Copy a Message between PubNub Keys 🎉
export default (request) => {
const xhr = require('xhr')
const pub_key = 'demo' // YOUR 2nd PUBLISH KEY
const sub_key = 'demo' // YOUR 2nd SUBSCRIBE KEY
const chncopy = request.channels[0]
const msgcopy = JSON.stringify(request.message)
const url = "http://pubsub.pubnub.com/publish/" + [
pub_key, sub_key, 0, chncopy, 0, msgcopy
].join('/')
// Copy Message to your other keys.
return xhr.fetch(url)
.then( result => request.ok(result) )
.catch( result => request.ok(result) )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.