Provides a way to register a callback to be invoked one or multiple times during the upload. The callback receives the current progress as two arguments, the number of bytes uploaded and the total number of bytes to upload.
Browser Limitations:
ERR_ALPN_NEGOTIATION_FAILED on HTTP servers.Compatible with platforms implementing the TransformStream WebAPI and supporting request body streaming.
import ProgressAddon from "wretch/addons/progress"
wretch("https://example.com/upload") // Note: HTTPS required for Chrome
.addon(ProgressAddon())
.onUpload((loaded, total) => console.log(`Upload: ${(loaded / total * 100).toFixed(0)}%`))
.post(formData)
.res()
Provides a way to register a callback to be invoked one or multiple times during the download. The callback receives the current progress as two arguments, the number of bytes downloaded and the total number of bytes to download.
Compatible with all platforms implementing the TransformStream WebAPI.