@indlekofer/ajax_json

1.1.3 • Public • Published

@indlekofer/ajax_json

npm version

Usage

import request from '@indlekofer/ajax_json';

let setting = {};
request(settings)
  .then((req) => {
    console.log(req.status);
    //containes the parsed json object
    console.log(req.responseJson);
  }, (req) => {
    //e.g.: timeout or json parser problems
    console.log(req.error);
  })

Parameters

settings: object settings
req: object (default XMLHttpRequest)

Settings

settings objekt

url: string (default: '/')
method: string (default: 'GET')
body: object request body
query: object request get
async: bool (default: true)
withCredentials: bool (default: false) seend cookies
auth: string (default false) base64 encoded authentication string

Errors

compare the req.error with the given error code constants

ERROR_JSON: invalid json response
ERROR_TIMEOUT: the request timed out
ERROR_REJECT: rejected request. e.g.: cors

Readme

Keywords

none

Package Sidebar

Install

npm i @indlekofer/ajax_json

Weekly Downloads

1

Version

1.1.3

License

MIT

Unpacked Size

10.9 kB

Total Files

8

Last publish

Collaborators

  • daind