1.0.0 • Published 6 years ago

uc-request v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Unchained UI

Request

NPM Version NPM Downloads

Low-level HTTP request with file upload and progress

Usage

import request from 'uc-log'

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