This is a migrated thread and some comments may be shown as answers.

Use Cloud Function from within another Cloud Function

1 Answer 43 Views
Cloud Code
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Alexej
Top achievements
Rank 1
Alexej asked on 16 Dec 2016, 02:45 PM

Hi,

how can one invoke a Cloud Function from within another Cloud Function? 

"Everlive.Sdk.$.businessLogic.invokeCloudFunction(cloudFunctionName, params).then(function (data) });" does not seem to work.

Thanks,

Alexej

 

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 20 Dec 2016, 12:18 PM
Hi Alexej,

The method businessLogic.invokeCloudFunction() is not available in Cloud functions yet.

You may invoke another cloud function by making an HTTP request from cloud code to its endpoint URL. Here is how a sample cloud function that invokes another cloud function will look like:

Everlive.CloudFunction.onRequest(function(request, response, done){
    var requestOptions = {
        method: 'GET',
        url: 'https://api.everlive.com/v1/{app-id}/functions/{function-name}[?parameter1=value1¶meter2=value2&...parameterN=valueN]',
        options: null
    };
     
    console.log(Everlive.version);
     
    Everlive.Http.request(requestOptions.method, requestOptions.url, requestOptions.options, function(error, success){
                    if (error) {
                console.log(JSON.stringify(error));
            } else {
                console.log(JSON.stringify(success));
            }
            done();
    });
});

Please note that cloud functions have restrictions so you should use HTTP requests with caution as described here.

Regards,
Martin
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
Cloud Code
Asked by
Alexej
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or