Minimal XHR request library
Installation
npm install rqst
Example
const get = // -> https://avatars.githubusercontent.com/u/25254?v=3
Guide
About the API
Doing basic success
requests the promise interface can be used. As soon as you want seperate callback handlers for cancellation, a promise falls short. This is where you can use the traditional callback-based API:
POST
const data = userId: 1 title: 'foo' body: 'bar'
Cancellation
Calling any of the http
requests (i.E. .get
, .put
) returns a function to abort a request. This is useful for example if you have a GET request inflight and the user switches pages on a SPA. You want to cancel that request since its no longer neccessary.
const abort = // aborts the request
Minimize bundle size
rqst
is already small as is but if you, for your specific project, only need let's say GET requests you can just require that:
const post = const get =
File Upload
Todo
Progress
Todo
Tests
npm test