I used setTimeout() in a function, passing the number of seconds to wait as a parameter. 2 seconds was spotty for me across various testing conditions, but I found 3 secs to work 100%.
function wait(seconds) {
return new Promise(resolve => setTimeout(resolve, seconds * 1000));
}
You could also wait for a condition to be true(API fully loaded) and set an interval to check that condition which would be more durable but could lead to other issues which you would likely want to include handling for fails or errors.