V8 service monetization
From DreamFactory
Toddappleton (Talk | contribs) |
Toddappleton (Talk | contribs) |
||
Line 4: | Line 4: | ||
var payload = { | var payload = { | ||
− | + | user_name: platform.session.user.email, | |
app_key: platform.session.api_key, | app_key: platform.session.api_key, | ||
− | + | time_stamp: (new Date()).toString() | |
}; | }; | ||
Revision as of 18:54, 29 June 2016
Count usage of a particular service, saving history in a database table. Each time a GET call is made on an API endpoint, write the transaction details to a 'TransactionHistory' table. Record the username, application key, and timestamp.
var payload = { user_name: platform.session.user.email, app_key: platform.session.api_key, time_stamp: (new Date()).toString() }; var result = platform.api.post("db/_table/TransactionHistory", {resource: [payload]}); if (result.status_code !== 200) { throw(JSON.stringify(result.content.error.message)); }