Start and Stop a timer

Question:

Is it possible to have a url to start a timer, and other url to stop a specific timer?

export async function get_BeginTimeout() {

const timer = setTimeout(() => {
console.log(‘Timer expired!’);
}, 60000);

//store the timer in a collection

return ok();

}

export async function get_StopTimeout() {

//get the timer object of the collection
const row= await wixData.query(“MyAdminEventsNotifications”).limit(1).find()

clearTimeout(row.items[0].timer)
return ok();

}

is it possible to do something like that?

Technically, yes.

Can be done using the http-functions.js method.

What are you trying to achieve though?
There might be a better way of doing it.

What I wanted is an endpoint to start a timer which triggers a function that calls an external api.
But sometimes I may want to cancel that request to that external api. So, I thought of cancelling the timer.
So far after many attemps I cannot apply this approach .
Any ideas?

An endpoint… to start a timer… which triggers a function - just to call another API?

This is very little info, we can only help you so much with this. You’ll have to give us a deep and detailed explanation of exactly what you’re trying to build, what this external API is, and what you are trying to achieve with it, in order for the community to suggest a more efficient way of approaching this.

Is this going to be a manual process or an automated one? What is the application for this? Help us to help you.