Skip to content

Instantly share code, notes, and snippets.

@sunnygleason
Created March 14, 2017 19:10
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/9e2de1d1f9f4e2c3fd21f49a6776ddab to your computer and use it in GitHub Desktop.
Save sunnygleason/9e2de1d1f9f4e2c3fd21f49a6776ddab to your computer and use it in GitHub Desktop.
PubNub IoT Time Series BLOCK w/ InitialState
export default (request) => {
const xhr = require('xhr');
const accessKey = "YOUR_ACCESS_KEY";
const bucketKey = "YOUR_BUCKET_KEY";
const event = request.message.event;
const http_options = {
"method": "POST",
"headers": {
"Content-Type": "application/json",
"X-IS-AccessKey": accessKey,
"X-IS-BucketKey": bucketKey,
"Accept-Version": "0.0.4"
},
body: JSON.stringify([event])
};
const url = "https://groker.initialstate.com/api/events";
return xhr.fetch(url, http_options).then((x) => {
request.message.is_result = x;
return request;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment