Skip to content

[ADD] Parameters in Cloud Functions #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class _MyAppState extends State<MyApp> {
//getSingleItem();
query();
//function();
//functionWithParameters();
//initUser();
}

Expand Down Expand Up @@ -179,4 +180,10 @@ class _MyAppState extends State<MyApp> {
var function = ParseCloudFunction('testFunction');
function.execute();
}

functionWithParameters() async {
var function = ParseCloudFunction('testFunction');
var params = {'plan': 'paid'};
function.execute(parameters: params);
}
}
3 changes: 2 additions & 1 deletion lib/src/objects/parse_function.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class ParseCloudFunction extends ParseObject {
/// Executes a cloud function
///
/// To add the parameters, create an object and call [set](value to set)
execute() async {
execute({Map parameters}) async {
var uri = _client.data.serverUrl + "$_path";
if (parameters != null) setObjectData(parameters);
var result = await _client.post(uri, body: json.encode(getObjectData()));
return super.handleResponse(result, ParseApiRQ.execute);
}
Expand Down