1.0.1 • Published 5 years ago

@deanacus/ajax v1.0.1

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

Ajax

A simple little wrapper around XMLHttpRequest to promisify getting and sending data.

Build solely as an excuse to get started learning how to create and resolve promises

Install

Use npm npm install --save @deanacus/ajax

Usage

Import the library into your file:

import '@deanacus/ajax'

Then, depending on if you want to get data, or send data, use the appropriate interface.

Get

To request data, call ajax.get()

Paramaters:

OptionValue typeDescription
endpointstringThe URL to which you would like to make the request
headersobjectAn object containing the key/value pairs to set as request headers

Send

To send data, call ajax.send()

Paramaters:

OptionValue typeDescription
endpointstringThe URL to which you would like to send the request
payloadanyThe data you wish to send to the enpoint. This is not processed in any way
headersobjectAn object container the key/value pairs to set as request headers