Reset guest token if rate limit is reached

This commit is contained in:
Alexander Sheiko 2021-01-05 15:15:27 +02:00
parent 56f5a2edc2
commit 142387af97

4
api.go
View file

@ -44,6 +44,10 @@ func (s *Scraper) RequestAPI(req *http.Request, target interface{}) error {
return fmt.Errorf("response status %s", resp.Status)
}
if resp.Header.Get("X-Rate-Limit-Remaining") == "0" {
s.guestToken = ""
}
return json.NewDecoder(resp.Body).Decode(target)
}