jaffy-rest-api

1.0.2 • Public • Published

Jaffy - RestAPI

RestAPI is a standalone rest client for javascript. If you find anything messy ? report me

jaffy.restAPI

Basic example

var a = new jaffy.restAPI();
a.setUrl("http://yourresturl");
a.GET(function(response){
    console.log(response);
});

Setup Rest URL

setUrl(url)

you can define relative or absolute url.

REST Methods

  • GET
  • POST
  • OPTIONS
  • PUT
  • DELETE
  • PATCH

Headers

  • setHeader(variable, value)

for example

var a = new jaffy.restAPI();
a.setUrl("http://yourresturl");
a.setHeader("Authorization", "Bearer AJDYOWOJMXL273jsiJs72js82==");
a.GET(function(response){
    console.log(response);
});

Query params

  • setParam(variable, value)

for example

var a = new jaffy.restAPI();
a.setUrl("http://yourresturl");
a.setParam("test", "1234");
a.GET(function(response){
    console.log(response);
});

Body as Formdata

  • setBody(variable, value)

for example

var a = new jaffy.restAPI();
a.setUrl("http://yourresturl");
a.setBody("test", "1234");
a.POST(function(response){
    console.log(response);
});

Body as Payload

  • setParam(variable, value)

for example

var a = new jaffy.restAPI();
a.setUrl("http://yourresturl");
a.setPayload("test", "1234");
a.POST(function(response){
    console.log(response);
});

Note: setParam() & setBody() will not work with only POST methods. also rest will be used as payload once you started using setParam()

Advanced features

sync(true|false)

use to make syncronous rest request. but this feature will block the execution of main thread. use only if it is really necessary.

Readme

Keywords

none

Package Sidebar

Install

npm i jaffy-rest-api

Weekly Downloads

2

Version

1.0.2

License

ISC

Unpacked Size

7.03 kB

Total Files

4

Last publish

Collaborators

  • santadreams