Giter VIP home page Giter VIP logo

js-transmission's Introduction

[email protected]

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

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

[email protected]

js-transmission's People

Contributors

0x1af2aec8f957 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.