Created
March 14, 2017 22:06
-
-
Save sunnygleason/313c72f257f077b9712aa293f84c67a5 to your computer and use it in GitHub Desktop.
PubNub IoT Messaging BLOCK w/ Wia
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 authKey = request.message.authKey; | |
const url = "https://api.wia.io/v1/events"; | |
const http_options = { | |
"method": "POST", | |
"headers": { | |
"Content-Type": "application/json", | |
"Authorization": "Bearer " + authKey | |
}, | |
body: JSON.stringify(request.message.event) | |
}; | |
return xhr.fetch(url, http_options).then((response) => { | |
request.message.wia_reply = JSON.parse(response.body); | |
return request; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment