Skip to content

Low-level HTTP request with file upload and progress

License

Notifications You must be signed in to change notification settings

unchainedui/request

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unchained UI

Request

NPM Version NPM Downloads

Low-level HTTP request with file upload and progress

Usage

import request from 'uc-request';

request.send({
  url: 'http://localhost/api/user.get',
  method: 'get'
}, res => {
  console.log(res);
});

Static methods

send(options, callback)

Creates the instance of the Request class and sends the requests. Returns the class instance.

Methods

send(options, callback)

Sends the request and calls callback.

options are:

  • url – string, URL
  • method – string, http method
  • headers – object, http headers
  • body – various, http request body
  • options – object, any other properties to set on XMLHttpRequest
  • onprogress – function, upload progress handler

callback(result)

  • result
    • status — https request status
    • body — response body. If JSON will be parsed.
    • error — error if request failed

abort()

Aborts the request.

License MIT

© velocityzen

About

Low-level HTTP request with file upload and progress

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published