1.0.8 ā€¢ Published 2 years ago

jaxo v1.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

āŒ› Jaxo HTTP Client

āš”ļø A lightweight JavaScript library for making AJAX requests

HTTP Client HTTP Client HTTP Client HTTP Client HTTP Client

šŸ”† Playground

Usage

import Jaxo from "jaxo";

Or include it via jsDelivr CDN:

<script src="https://cdn.jsdelivr.net/npm/jaxo/build/index.min.js"></script>
<!-- access via global object Jaxo : window.Jaxo -->

Documentation

const options = {
  method: 'GET', //-> default
  timeout: 2000, //-> default
  async: true,   //-> default
  headers: {
    "Accept": "application/json, text/plain",
    "Content-Type": "application/json"
  },
  onProgress: (percent) => { //-> upload and download progress event
    console.log(percent)
  }
}

// Send request
Jaxo.send(options: Object | String) : Promise

// cancel request (xhr is XMLHttpRequest object)
Jaxo.xhr.abort()

GET Example

Jaxo.send('https://jsonplaceholder.typicode.com/users')
  .then(response => {
    console.log(response)
  })
  .catch(e => {
    console.log(e.message)
  });

POST Example

document.getElementById('form-file')
  .addEventListener('submit', e => {

    let file = e.target.elements[0].files[0];

    const formData = new FormData();
    formData.append('key', 'your imgbb key')
    formData.append('image', file);
    formData.append('name', 'testing file');

    let response = await Jaxo.send({
      url: 'https://api.imgbb.com/1/upload',
      method: 'POST',
      data: formData
    })
      .then(response => {
        console.log(response);    
      })
      .catch(error => {
        console.log(error.message);
      });
});

Notes

  • All pull requests are welcome.

License

MIT

1.0.8

2 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago