Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Created October 16, 2012 03: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 aaronksaunders/33f0e35007257ca68cfa to your computer and use it in GitHub Desktop.
Save aaronksaunders/33f0e35007257ca68cfa to your computer and use it in GitHub Desktop.
My First Node.ACS App
/**
* service definition file
*/
logger.setLevel('DEBUG');
ACS.init("yourkeys","yourkeys");
// GUESS I NEED THIS TO MAKE IT RUN
api.index = function(req, res) {
};
// glo
ACS.Users.login({
login: 'DONOTDELETE',
password: 'admin'
}, function(data) {
console.log('User logged in!');
console.log(JSON.stringify(data));
if ( data.success === true ) {
console.log(data.meta.session_id);
loadItUp(data.meta.session_id);
}
});
/**
* loop through JSON file
*/
function loadItUp(session_id /* session id needed for calls*/) {
var placeJSON = require('/venues');
for (var c in placeJSON) {
// create the model and add it to the collection
var params = placeJSON[c];
// add session id to api parameters
params['session_id'] = session_id;
// make the call
ACS.Places.create( params , function(data) {
if ( data.success === true ) {
console.log(JSON.stringify(data));
} else {
console.log(JSON.stringify(data.meta));
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment