1.1.6 • Published 6 years ago

js-transmission v1.1.6

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

transmission.js@1.1.6

matters needing attention

Be based on Asynchronous Javascript And XML! In the future version, Access to Fetch API!

install transmission.js

npm install js-transmission --registry=https://registry.npm.taobao.org

use transmission.js

ES6 import

// For the sake of standardization, only support ES6 module!
import transmission from 'js-transmission';

transmission({
  url: "https://baidu.com",
  type: "GET",
  async: false,
  header: {
    'User-Agent': 'js-transmission'
  },
  data() {
    return {
      message: "hello transmission.js!"
    }
  },
  beforeSend() {
    // modify data
    return { // modify data
      message: "hello world!"
    }
  },
  sending() {
    //so do...
  },
  sent() {
    //so do...
  },
  inProcess() {
    //so do
  },
  beforeSuccess: (data, sendObject, ResponseHeaders) => {
    // data, sendObject, ResponseHeaders
    console.log(data)
    console.log(sendObject)
    console.log(ResponseHeaders)
  },
  success(response, headers) {
    // typeof response === 'object' //true
    console.dir(response),
    console.dir(headers)
  },
  error(error, statusData) {
    console.warn(error);
    console.dir(statusData)
  }
});

//GET example

transmission('https://baidu.com?search=transmission.js')
  .then(r => {
    console.dir(r)
  })
  .catch(e => {
    console.error(e)
})

//POST example

transmission({
  url: 'https://baidu.com',
  type: "POST",
  data:{message:"hello world!"}
})
.then(r => {
  console.dir(r)
})
.catch(e => {
  console.error(e)
})

License

MIT

transmission.js@1.1.6

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago