Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation to cancel request #264

Merged
merged 1 commit into from
Aug 20, 2021
Merged

Conversation

chakrihacker
Copy link
Collaborator

@chakrihacker chakrihacker commented May 18, 2021

closes #246

Copy link
Member

@jamonholmgren jamonholmgren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chakrihacker Apologies for taking so long on this -- I didn't see it until now.

Looks good to me. This API is kinda awkward, but at least people will know how to do it.

@jamonholmgren jamonholmgren merged commit 962ff5b into master Aug 20, 2021
@jamonholmgren jamonholmgren deleted the add-cancel-readme branch August 20, 2021 17:14
@chakrihacker
Copy link
Collaborator Author

Thanks, what do you mean by the awkward? I have been using this and it's working greatly in my projects.

Just curious how would you cancel a request??

@infinitered-circleci
Copy link

🎉 This PR is included in version 2.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@jamonholmgren
Copy link
Member

what do you mean by the awkward

This is just my opinion, but creating a CancelToken, passing it in, and then running a method on that feels odd to me.

Ideally, one could do something like this, hanging a function off of the promise object or something:

const api = create({ baseURL: 'github.com' })
const responsePromise = api.get('/users', {})
// To cancel request
responsePromise.cancel()

I recognize that hanging methods like cancel off of a promise is bad form. If one was worried about forward compatibility, we could do something like responsePromise.apisauceCancel(). Then, we just internally provide a cancel token and hide that implementation away from the user.

None of this is critical, though. Just an opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cancellation Request
3 participants