Skip to content

Instantly share code, notes, and snippets.

@lbrenman

lbrenman/app.js

Last active Aug 16, 2019
Embed
What would you like to do?
Node.js example of accessing Axway/Appcelerator MBaaS (ArrowDB/ACS) - user and photo API
var fs = require('fs');
var ArrowDBAppKey_Dev = '<ACS DEV APP KEY>';
var ArrowDBAppKey_Prod = '<ACS PROD APP KEY>';
var ArrowDB = require('arrowdb'),
arrowDBApp = new ArrowDB(ArrowDBAppKey_Prod);
var loginParams = {
login: 'a',
password: '1234'
};
arrowDBApp.usersLogin(loginParams, function(err, result) {
if (err) {
console.error("Login error:" + (err.message || result.reason));
} else {
console.log("Login successful!");
console.log("UserInfo: " + JSON.stringify(result.body.response.users[0]));
getPhotos();
}
});
function getPhotos() {
arrowDBApp.photosQuery({
limit: 10
}, function(err, result) {
if (err) {
console.error(err.message);
} else {
storePhoto();
result.body.response.photos.forEach(function (photo) {
console.log(photo);
});
}
});
}
function storePhoto() {
arrowDBApp.photosCreate({
photo: fs.createReadStream('photo.jpg'),
custom_fields: {
age: {
low: 22,
high: 34
},
gender: "female"
}
}, function(err, result) {
if (err) {
console.error(err.message);
} else {
console.log(result.body.response.photos[0]);
}
});
}
{
"name": "nodembaas",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"arrowdb": "^1.0.11"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.