{
"appid": "hOes1tGp_a5JQ445PjKwyL5M",
"appkey": "6549c1aef814b4e8bdf5d3d25194ebeee45",
"apptitle": "My Application",
"connectiontag": "X.Y.Z",
"host": "https://yourdomain.feedhenry.com",
"projectid": "hOe91u9jDDuVkuhKNKxRoqBp"
}
function success (res) {
console.log(res)
}
function fail (msg, err) {
console.error(msg, err);
}
$fh.cloud({
"path": "/api/v1/user/create", // URL is automatically configured
"method": "POST", // e.g. GET, PUT, DELETE, OPTIONS
"contentType": "application/json",
"data": { "username": "testuser"}, // data to send to the server
"timeout": 25000 // Timeout in milliseconds
}, success, fail);
NSDictionary * headers = [NSDictionary dictionaryWithObject:
@"application/json" forKey:@"contentType"];
NSDictionary * data = [NSDictionary dictionaryWithObject:
@"testuser" forKey:@"username"];
NSString *mtd = @"POST";
NSString *url = @"/api/v1/user/create";
FHCloudRequest * action = (FHCloudRequest *) [FH buildCloudRequest:url
WithMethod:@mtd AndHeaders:headers AndArgs:data];
[action execAsyncWithSuccess:^(FHResponse * actRes){
NSDictionary * resData = actRes.parsedResponse;
// ...
} AndFailure:^(FHResponse * actFailRes){
// Errors are in the rawResponse string
NSLog(@"Failed to read tweets. Response = %@", actFailRes.rawResponse);
}
];
Header[] headers = new Header[1];
headers[0] = new BasicHeader("contentType", "application/json");
FHCloudRequest request = FH.buildCloudRequest(
"/api/v1/user/create",
"POST",
headers,
new JSONObject().put("username", "testuser")
);
request.executeAsync(new FHActCallback() {
@Override
public void success(FHResponse res) {
try{
// process response data
} catch(Exception e){
Log.e(TAG, e.getMessage(), e);
}
}
@Override
public void fail(FHResponse res) {
Log.e(TAG, res.getErrorMessage(), res.getError());
}
});
IDictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("contentType", "application/json");
IDictionary<string, object> data = new Dictionary<string, object>();
data.Add("username", "testuser");
FHResponse response = await FH.Cloud("/api/v1/user/create", "POST", headers, data);
if(null == response.Error)
{
//no error occured, the request is successful
string rawResponseData = response.RawResponse;
//you can get it as JSONObject (require Json.Net library)
JObject resJson = response.GetResponseAsJObject();
//process response data
}
else
{
//error occured during the request, deal with it.
//More infomation can be access from response.Error.InnerException
}
// Get a reference to the cloud API
var $fh = require('fh-mbaas-api');
// Called when the operation completes
function createCallback (err, res) {
if (err) {
console.log(err);
} else {
console.log(res);
}
}
// Create a user in the Users Mongo collection
$fh.db({
act: 'create',
type: 'Users'
fields: {
name: 'John Doe',
age: 32
}
}, createCallback);
var $fh = require('fh-mbaas-api');
var app = require('express')();
var mbaasExpress = $fh.mbaasExpress();
var port = process.env.FH_PORT || process.env.VCAP_APP_PORT || 8001;
// list the endpoints which you want to make securable here
var securableEndpoints = ['hello'];
// Note: the order which we add middleware to Express here is important!
app.use('/sys', mbaasExpress.sys(securableEndpoints));
app.use('/mbaas', mbaasExpress.mbaas);
// Note: important that this is added just before your own Routes
app.use(mbaasExpress.fhmiddleware());
Add custom routes here...
// Important that this is last middleware added!
app.use(mbaasExpress.errorHandler());
var server = app.listen(port, function() {
console.log("App started at: " + new Date() + " on port: " + port);
});