1.2.6 • Published 2 years ago

@deadlyjack/ajax v1.2.6

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

Very Small XHR

A simple, tiny library to make ajax calls.

Usage

import ajax from '@deadlyjack/ajax';

const options = {
  url: "https://example.com",
  method: "get",
  data: {
    test: "this is test"
  },
  responseType: "json",
  contentType: "application/json"
};
ajax(options)
.then(res=>{})
.catch(err=>{});

/**
 * @function ajax
 * @param {object} [options]
 * @param {string} [options.url] URL
 * @param {"get"|"post"|"delete"|"patch"|string} [options.method] method of the request
 * @param {object} [options.data] request data
 * @param {"html"|"json"|"svg"|"text"|"xml"|"arraybuffer"|"document"} [options.responseType] response type
 * @param {"application/json"|"application/x-www-form-urlencoded"} [options.contentType] reqruest content type
 * @param {function(response):void} [options.onsuccess] callback function
 * @param {function(response):void} [options.onload]  callback function
 * @param {function} [options.onloadend]  callbackfunction
 * @param {boolean} [options.response] if true return response instread of xhr object
 * @param {function(xhr):void} [options.xhr] configure xhr object
 * @param {function(err):void} [options.onerror] callback function
 * @param {boolean} [options.serialize = true] serialize object or not
 * @returns {Promise<XMLHttpRequest|Object>}
 */
1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago