NodeJS stdlib Post
'use strict'; | |
var url = require('url'); | |
var creds = require('./creds.js'); | |
var https = require('https'); | |
var scheme = 'https'; | |
var hostname = 'api.tempo-db.com'; | |
var baseUrl = scheme + '://' + hostname; | |
var auth = 'Basic ' + new Buffer(creds.key + ':' + creds.secret).toString('base64'); | |
var seriesKey = '1_D90343085872CA9C_687_0_2000'; | |
function uploadEntry(cb){ | |
var data = []; | |
data.push({t: new Date(), v: Math.random() * 50}); | |
var body = JSON.stringify(data); | |
var headers = { | |
Authorization: auth, | |
'Content-Type': 'application/json', | |
'Content-Length': body.length | |
}; | |
var opts = { | |
host: hostname, | |
port: 443, | |
path: '/v1/series/key/' + seriesKey + '/data/', | |
method: 'POST', | |
agent: false, | |
headers: headers | |
}; | |
// console.log('sending', data[0]); | |
var req = https.request(opts,cb); | |
req.on('error', function(e) { | |
console.err('error', e); | |
}); | |
req.write(body); | |
req.end(); | |
}; | |
function callback(result){ | |
console.log('statusCode', result.statusCode); | |
} | |
setInterval(uploadEntry.bind(null, callback), 1000); | |
setInterval(gc, 1000); |
This comment has been minimized.
This comment has been minimized.
As requested.
|
This comment has been minimized.
This comment has been minimized.
This is master without the GC routine.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
This is a summary of allocated objects in master.