Skip to content

Instantly share code, notes, and snippets.

@sunnygleason
Created March 14, 2017 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sunnygleason/313c72f257f077b9712aa293f84c67a5 to your computer and use it in GitHub Desktop.
Save sunnygleason/313c72f257f077b9712aa293f84c67a5 to your computer and use it in GitHub Desktop.
PubNub IoT Messaging BLOCK w/ Wia
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