ofetch icon indicating copy to clipboard operation
ofetch copied to clipboard

feat: add `fetch[method](url)` aliases

Open Kiansa opened this issue 1 year ago • 2 comments

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

Kiansa avatar Sep 29 '24 21:09 Kiansa

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

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               

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 08 '24 15:10 codecov[bot]

Thanks for nice PR dear @Kiansa.

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

pi0 avatar Oct 08 '24 15:10 pi0