Open nathakits opened 3 years ago
the token expires in 1 hour, so could use date.now() to
async getToken() { var token_response = get request var expiration_time = token_response .expires_in (1 hour) var start_time = Date.now()
var obj = { token: "", start_time: "", expiration_time: "" } return obj }
var Search() { if (start_time - current_time < 1 expiration_time) { get request } else { getToken() } }
This could be done in several ways.