1.0.8 • Published 8 years ago

weex-http v1.0.8

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
8 years ago

weex-http

weex simple http lib

Build Status Coverage Status

Installing

npm i weex-http --save-dev
# or
yarn add weex-http --dev

Example

Performing a GET request

import weexHttp from 'weex-http'

weexHttp.get('/user', {
    ID: 12345
})
.then(function (response) {
    console.log(response)
})
.catch(function (error) {
    console.log(error)
})

Performing a POST request

weexHttp.post('/user', {
    firstName: 'Fred',
    lastName: 'Flintstone'
})
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
})

Creating an instance

You can create a new instance of axios with a custom config.

weexHttp.create(config)

var instance = weexHttp.create({
    baseURL: 'https://some-domain.com/api/',
    timeout: 1000,
    headers: {'X-Custom-Header': 'foobar'}
})

Options

  • timeout number default: 10000 ms
  • headers any default: {}
  • transformRequest Function[] default: []
  • transformHeaders Function[] default: []
  • transformResponse Function[] default: []

Instance methods

The available instance methods are listed below. The specified config will be merged with the instance config.

weexHttp#get(url[, data, config])

weexHttp#delete(url[, data, config])

weexHttp#head(url[, data, config])

weexHttp#post(url[, data, config])

weexHttp#put(url[, data, config])

weexHttp#patch(url[, data, config])

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago