Created
March 14, 2017 19:10
-
-
Save sunnygleason/9e2de1d1f9f4e2c3fd21f49a6776ddab to your computer and use it in GitHub Desktop.
PubNub IoT Time Series BLOCK w/ InitialState
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 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