mattroumaya / surveymonkey

Access your SurveyMonkey data directly from R!
https://mattroumaya.github.io/surveymonkey/
Other
42 stars 10 forks source link

Allow for 401Unauthorized failure during login #72

Closed GregSutcliffe closed 3 years ago

GregSutcliffe commented 3 years ago

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.

sfirke commented 3 years ago

closes #60 ! 🎉