axios-add-jsonp

0.1.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i axios-add-jsonp

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

5.17 kB

Total Files

4

Last publish

Collaborators

  • ccbabi