Run function after api is done running

Options
I have some image manipulation that needs to happen. It's a heavy load that involves external API's.

I want to run a function every time a new row is added to a table.

I know I can do this with tasks, based on a repeat interval and just keep checking for new records over and over.

But, is there a way to run a function after every row is added?

Or, after an API call has already been sent back to the client?

I don't want the client to have to wait for the response.

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Yes, you could add that function at the end of the function stack where that record is added. So when the record is added then your other logic is automatically triggered
  • Kevin Wasie
    Kevin Wasie Member
    Options
     Clarification ... I want the function to run after the response has already been sent back to the client. 

    I do not want the client to have to wait on the manipulation. 

    So, I want to run an API, send the response, and then run the function. 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Ah got it, then yes you would need to run this logic in a background task. 

  • is it possible for the first API to send a webhook to trigger the function after it has completed its run?