ofetch icon indicating copy to clipboard operation
ofetch copied to clipboard

feat: add support for Request / Response progress

Open picunada opened this issue 2 years ago โ€ข 5 comments

๐Ÿ”— Linked issue

Issue #45

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • [ ] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [ ] ๐Ÿ‘Œ Enhancement (improving an existing functionality like performance)
  • [x] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

Added support for Request / Response progress.

๐Ÿ“ Checklist

  • [x] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

picunada avatar Aug 24 '23 05:08 picunada

Codecov Report

Merging #277 (e8af744) into main (da64d78) will increase coverage by 1.10%. The diff coverage is 96.82%.

:exclamation: Current head e8af744 differs from pull request most recent head 12c07f1. Consider uploading reports for the commit 12c07f1 to get more accurate results

@@            Coverage Diff             @@
##             main     #277      +/-   ##
==========================================
+ Coverage   92.00%   93.10%   +1.10%     
==========================================
  Files           5        5              
  Lines         450      609     +159     
  Branches      102      109       +7     
==========================================
+ Hits          414      567     +153     
- Misses         36       42       +6     
Files Coverage ฮ”
src/fetch.ts 96.50% <96.82%> (+1.10%) :arrow_up:

... and 3 files with indirect coverage changes

codecov[bot] avatar Aug 24 '23 05:08 codecov[bot]

Hello, I would like to request help for this PR.

For now I only implemented progress for req/response with json.

First commit here working probably only within Browser env. How can I add support for Node streams? Also requesting refactor advices :)

picunada avatar Aug 24 '23 06:08 picunada

Hi dear @picunada thanks for picking on this and nice idea for initial POC.

I think in order to move this idea forward, i am mainly looking forward to exposing minimum enough hooks in order to be able creating fetchWithProgrsss utility by wrapping $fetch, this way we can both make sure not adding overhead to the core and also implement platform dependent implementations. Also we could directly support a binary transform to allow all kind of responses. Not sure how we can wrap native utils such as response.formData() (one idea might be wrapping Response)

Basically what am i looking forward for next steps is to somehow introduce something like TrackedRequest / TrackedResponse wrapper classes. They might make this feature complete

pi0 avatar Oct 26 '23 18:10 pi0

Hi dear @picunada thanks for picking on this and nice idea for initial POC.

I think in order to move this idea forward, i am mainly looking forward to exposing minimum enough hooks in order to be able creating fetchWithProgrsss utility by wrapping $fetch, this way we can both make sure not adding overhead to the core and also implement platform dependent implementations. Also we could directly support a binary transform to allow all kind of responses. Not sure how we can wrap native utils such as response.formData() (one idea might be wrapping Response)

Basically what am i looking forward for next steps is to somehow introduce something like TrackedRequest / TrackedResponse wrapper classes. They might make this feature complete

Looking forward to this

Dmytro-Tihunov avatar Oct 27 '23 10:10 Dmytro-Tihunov

Can this PR be expected to be implemented soon? It would be really nice to have on Nuxt 3!

ChrisGV04 avatar Jan 24 '24 00:01 ChrisGV04