Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to retrieve data with the getHttpsCallable method

I'm working on a flutter app and like to get data from a firebase cloud function. In the plugin cloud_functions 0.2.0 the method getHttpsCallable is introduced, but there is nowhere a description how to use it.

How can I access the data?

I tried the following, but it only prints "Instance of 'HttpsCallable'"

var result = CloudFunctions.instance.getHttpsCallable(
    functionName: 'addUser',
    parameters: {
      "name": 'blabla',
      "email": 'blabla'
    }
  );
print(result);
like image 877
Neli Avatar asked Jun 28 '26 15:06

Neli


1 Answers

You can await the call method of httpsCallable.

The example app has the usage:

                try {
                  final HttpsCallableResult result = await callable.call(
                    <String, dynamic>{
                      'message': 'hello world!',
                      'count': _responseCount,
                    },
                  );
                  print(result.data);
                  setState(() {
                    _response = result.data['repeat_message'];
                    _responseCount = result.data['repeat_count'];
                  });
                } on CloudFunctionsException catch (e) {
                  print('caught firebase functions exception');
                  print(e.code);
                  print(e.message);
                  print(e.details);
                } catch (e) {
                  print('caught generic exception');
                  print(e);
                }
like image 156
Collin Jackson Avatar answered Jul 01 '26 04:07

Collin Jackson