Skip to content

Commit

Permalink
Progress event doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Mar 5, 2017
1 parent 616cbb3 commit 9bacdbc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,23 @@ Alternatively, you can use the `.ok(callback)` method to decide whether a respon
// reads 404 page as a successful response
})

## Progress tracking

SuperAgent fires `progress` events on upload and download of large files.

request.post(url)
.attach(file)
.on('progress', event => {
/* the event is:
{
direction: "upload" or "download"
percent: 0 to 100 // may be missing if file size is unknown
total: // total file size, may be missing
loaded: // bytes downloaded or uploaded so far
} */
})
.end()

## Promise and Generator support

SuperAgent's request is a "thenable" object that's compatible with JavaScript promises and `async`/`await` syntax. Do not call `.end()` if you're using promises.
Expand Down

0 comments on commit 9bacdbc

Please sign in to comment.