Skip to content

Conversation

endel
Copy link

@endel endel commented May 30, 2025

Hi there 👋 I hope all is well @lukeed!

This PR adds the possibility to provide a signal from AbortController and handles abort errors by assigning .aborted = true to the Error instance.

I noticed the test-suite is currently using the reqres.in external service, which currently requires a "free tier API key", and limits those requests to 100/day. I've added the free API Key in the tests, but ideally it would be best to have an http server on the side, just like you have here, that responds with the expected results instead.

Usage

import httpie from "httpie"

const controller = new AbortController();

httpie.get("...url", { signal: controller.signal }).
  then(() => {/* ... */}).
  catch((err) => {
    if (err.aborted) {
      // request has been aborted!
    }
  });

controller.abort();

Please let me know if you have feedback - I've been using httpie on colyseus.js for years and it's been serving me very well!

All the best!

@endel
Copy link
Author

endel commented May 30, 2025

Just pushed to include the "types" key on exports list, so editors (e.g. VSCode) can pick the types up for auto-completion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant