Is it possible to call async network request in Codeless Business Logic?


I want to ask if it’s possible to make async network request in Codeless and how?

Thank you.

Hello @irwancheung

What do you mean async request?
Could you please provide an example?

I mean non blocking request. I have a custom API service for new user registration which after create a User data, it will call external API to which return avatar image, then save it in new user record, and finally return success response.

I want this external API request to be non blocking so it can return success response immediately after create user data while it process the external request.

just to clarify, you have an APIService (A) to create a user and inside the API Service (A) you’ve got a request to another API Service (B), is that correct?

If so, the next question is: is the Service A depend on the result from the Service B?

Yes. This API Service B can be either internal (Backendless API) or external (another 3rd party) service. When A calls B, I want it not to wait for response from B and continue to next code.

Alright, I got it

It is impossible to call an API Service asynchronously in the Codeless system, because each next block is executing only when the previous one is finished.

Your case sounds more like: call an event and do not expect any response from that
So, I can propose you the following approach:

  1. create a Custom EventHandler

  2. make it “Non Blocking”

  3. request it from an API Service

btw, in order to minimize efforts you can just create the EventHandler and call inside the API Service (B)

I see. I thought Event Handler only run automatically when certain event was executed.
Thanks! I will try your solution.