Answer the question
In order to leave comments, you need to log in
How not to execute a request within 30 minutes?
Express sends a request to a third-party api to receive data and writes them to a file, how to make sure that the file is not updated within 30 minutes and a request is not sent to a third-party api?
Answer the question
In order to leave comments, you need to log in
let lastRequested = new Date()
if (new Date() - lastRequested > 1000 * 60 * 30) { // 1000 мс * 60 сек * 30 мин
lastRequested = new Date()
// тут запрос
//
// а еще лучше обновить lastRequested = new Date()
// когда запрос вернется успешно
// чтобы в случае провала его можно было повторить быстрее чем через полчаса
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question