Last active
February 7, 2017 23:27
-
-
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 π
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
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