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

Call helper functions/code from within cloud functions

1 Answer 56 Views
JavaScript SDK
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jonathan Salomon
Top achievements
Rank 1
Jonathan Salomon asked on 13 Mar 2017, 07:00 PM

I am wondering what the best way is to use general purpose code from within cloud functions. For, example I have several cloud functions from where I want to be able to send an SMS through Twilio integration. So I was thinking to define a cloud function that does general purpose SMS sending, that I could call from another cloud function. Is this the recommended approach? I wouldn't want to repeat very similar code in several cloud functions.

I tried something like this which did not work:

Everlive.Sdk.withMasterKey().businessLogic.invokeCloudFunction('sendSms', params)

 

Thanks!

1 Answer, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 14 Mar 2017, 02:58 PM
@Jonathan

The best practice really depends on your use case. My feeling is that the integrated function for sending SMS provides good encapsulation so it may be used from whatever you would like without further encapsulating it in a separate function. The choice however is at the discretion of the developer.

The reason the code you supplied is not working is explained in this forum post along with another approach.

I hope this helps.

Regards,
Anton Dobrev
Telerik by Progress
 
Everlive is now Telerik Backend Services, and is part of the Telerik Platform.
 
Tags
JavaScript SDK
Asked by
Jonathan Salomon
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Share this question
or