Skip to content

Instantly share code, notes, and snippets.

@stephenlb
Last active February 7, 2017 23:27
Show Gist options
  • Save stephenlb/e4ba0caa0aec6045887ff0b231b62c0e to your computer and use it in GitHub Desktop.
Save stephenlb/e4ba0caa0aec6045887ff0b231b62c0e to your computer and use it in GitHub Desktop.
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