Skip to content

Instantly share code, notes, and snippets.

@ProbablePrime
Last active May 6, 2016 23:59
Show Gist options
  • Save ProbablePrime/2f1bd5c8140ce9ad8df8037244e38d65 to your computer and use it in GitHub Desktop.
Save ProbablePrime/2f1bd5c8140ce9ad8df8037244e38d65 to your computer and use it in GitHub Desktop.
var WsabiClient = require('wsabi-client-bacon');
var wsabi = new WsabiClient('https://beam.pro');
wsabi.liveUrl = '/api/v1/live';
wsabi.socket.on('open', doIt);
function login(username, password) {
console.log('login');
return wsabi.post('/api/v1/users/login', {username, password});
}
function postData() {
var jsonString = 'YOUR JSON HERE ON ONE LINE YAY';
var json = JSON.parse(jsonString);
console.log('post');
return wsabi.put('/api/v1/tetris/versions/' + <version id here>, json );
}
function doIt() {
login('ProbablePrime', '<password>').then(postData).then(function () {
console.log('done');
}).catch(function (err) {
console.log(err);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment