If the user cannot actually login with the given token (for example, a typo when setting up the options() call :P) then the SM API might return 401 unauthorized. In this situation, the headers will not contain the rate limit info, and the function will bomb out at line 63 because it's missing an argument:
You have requests left today before you hit the limit
Error in if (as.numeric(out$headers$x-ratelimit-app-global-day-remaining)%%20 == :
argument is of length zero
Simple fix is to check the return of the API call before trying to do anything with it.
If the user cannot actually login with the given token (for example, a typo when setting up the
options()
call :P) then the SM API might return 401 unauthorized. In this situation, the headers will not contain the rate limit info, and the function will bomb out at line 63 because it's missing an argument:Simple fix is to check the return of the API call before trying to do anything with it.