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

feat: add fetch[method](url) aliases #447

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Kiansa
Copy link

@Kiansa Kiansa commented Sep 29, 2024

This commit refactors the fetch function in the src/fetch.ts file to add method aliases for common HTTP verbs. The aliases include get, post, put, delete, patch, head, and options. These aliases simplify the usage of the fetch function by allowing developers to use more intuitive method names instead of manually specifying the HTTP method in the options object.

The changes also include updating the types.ts file to define the FetchWithAliases type, which extends the existing $Fetch type and adds the method aliases as properties.

This enhancement improves the readability and maintainability of the codebase by providing a more expressive and concise API for making HTTP requests.

Closes #282

@pi0 pi0 changed the title refactor(fetch): Add method aliases for HTTP verbs feat: add fetch[method](url) aliases Oct 8, 2024
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.05%. Comparing base (27996d3) to head (f86d417).
Report is 53 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #447       +/-   ##
===========================================
+ Coverage   56.86%   70.05%   +13.18%     
===========================================
  Files          16       17        +1     
  Lines         728      531      -197     
  Branches      113      137       +24     
===========================================
- Hits          414      372       -42     
+ Misses        303      148      -155     
  Partials       11       11               

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pi0
Copy link
Member

pi0 commented Oct 8, 2024

Thanks for nice PR dear @Kiansa.

I'm gonna some time to think about API and overhead but positive about DX benefits.

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.

Request method to function alias
2 participants