Ben Walker
Posts: 0
Joined: Mon Jan 19, 2015 2:13 pm

delay REST service using setTimeout()

I am trying to add some data to a DB. Then, after a set period of time, I'd like that data to delete.

I'm using a create service, and a delete service. Upon success of the create service, I'd like a given period of time to elapse, then I want the delete service to run.

I have mapped the delete service to run at the completion of the create service. I tried inserting some "run JS" (a setTimeout() function) between the two to delay the delete service, but it doesn't seem to work.

Anyone know how I might delay the running of the delete service?

Thanks!

Bruce Stuart
Posts: 0
Joined: Fri Oct 24, 2014 4:42 am

delay REST service using setTimeout()

Ben,

How about this - instead of putting a delay between them - in the success even of the create service just insert this code?:

setTimeout( service_delete.execute({}) , 3000);

that's 3 seconds of delay..... more or less based on your appetite.....

and - also of use in the future at some point will be setInterval ......

of course - put your service name in place of my made up service name...

Best,
Bruce

Return to “Issues”