Calling a third party api from cloud code or directly on view

Hi,

I have to validate two fields by using a third party api on button click.
What should i use cloud code task or directly hit api on button click.

Hi @taranbirbajwa

I would use a CloudCode task that you call directly from the app when the user press the button.

  • Reason being that with using a CC task, you have the CC Invocation History to look at if something goes wrong with your API call in production.

If your app flow does not require a synchronous validation, you could have the validation happen asynchronously with calling the CC task via a webhook.

If anyone has some reasons for calling an API directly from the app, I’d like to know your thoughts.

  • Only reason I can think to call an API directly from the app is if the call is directly on the local network (VPN network) of the device or maybe if for some geographical/other reason you don’t want to route the API call through CloudCode.