0.1.0 • Published 6 years ago

axios-add-jsonp v0.1.0

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

axios-add-jsonp

Add a jsonp method to axios

Install

$ npm install axios-add-jsonp --save

Example

Unifies all requests

import request from 'axios-add-jsonp'

request.jsonp('/api/123', { bar: foo, foo: bar }).then(res => {
  // do some thing
})

request.get('/api/123', { bar: foo, foo: bar }).then(res => {
  // do some thing
})

request.post('/api/123', { bar: foo, foo: bar }).then(res => {
  // do some thing
})

The form request is created, and the mode of usage remains unchanged

import { create } from 'axios-add-jsonp'

const request = create({
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  }
})

request.post('/api/123', { bar: foo, foo: bar }).then(res => {
  // do some thing
})

Api

The usage method is basically the same as axios and jsonp, see axios and jsonp.

Format is as follows:

request.<method>(<url>, [<data>], [<config>]): Promise

Note: all methods are in this format, including GET, DELETE, HEAD, OPTIONS.

Promises

axios-add-jsonp depends on a native ES6 Promise implementation to be supported. If your environment doesn't support ES6 Promises, you can polyfill.

License

MIT

0.1.0

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago