Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mmf-fe/weex-http
weex simple http lib
https://github.com/mmf-fe/weex-http
http weex
Last synced: about 2 months ago
JSON representation
weex simple http lib
- Host: GitHub
- URL: https://github.com/mmf-fe/weex-http
- Owner: MMF-FE
- License: apache-2.0
- Created: 2017-02-25T08:44:51.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-15T03:32:35.000Z (over 7 years ago)
- Last Synced: 2024-12-10T00:58:00.528Z (2 months ago)
- Topics: http, weex
- Language: TypeScript
- Size: 53.7 KB
- Stars: 11
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# weex-http
weex simple http lib[![Build Status](https://img.shields.io/travis/MMF-FE/weex-http.svg?style=flat-square)](https://travis-ci.org/MMF-FE/weex-http)
[![Coverage Status](https://img.shields.io/coveralls/MMF-FE/weex-http.svg?style=flat-square)](https://coveralls.io/r/MMF-FE/weex-http?branch=master)## Installing
```
npm i weex-http --save-dev
# or
yarn add weex-http --dev
```## Example
Performing a GET request
```js
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
```js
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])
```js
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]])