aishek / axios-rate-limit

Rate limit for axios
MIT License
237 stars 35 forks source link

consider cancelled requests #50

Closed mikevinmike closed 6 months ago

mikevinmike commented 2 years ago

should resolve issue #21

petrkotek commented 6 months ago

BUMP - @aishek, can you please consider merging this?

I can confirm that this resolves my issue with 'lagging' auto-completion when I use rate limiting & cancel queued requests. (Thanks @mikevinmike! ❤️)

// First, cancel in-progress requests as the previous suggestions no longer matter.
    this.suggestAddressesCancelTokenSource?.cancel()
    this.suggestAddressesCancelTokenSource = axios.CancelToken.source();

    // Issue the new request.
    return this.http.get(API_URL + '/suggest_addresses', {
      params: { query },
      cancelToken: this.suggestAddressesCancelTokenSource.token
    })
aishek commented 6 months ago

Well, it is better later than never. Thanks!

aishek commented 6 months ago

Published in version 1.3.1