Skip to content
This repository was archived by the owner on Apr 17, 2022. It is now read-only.
/ http Public archive

ajax/http wrapper for browser and node that allows config inheritance ( uses fetch API when present )

License

Notifications You must be signed in to change notification settings

kiltjs/http

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ff4c23e · Mar 24, 2020
Mar 24, 2020
Dec 12, 2019
May 30, 2019
Feb 16, 2018
Nov 20, 2018
Mar 22, 2017
Apr 28, 2017
Apr 26, 2017
Mar 24, 2020
Mar 24, 2020
Mar 22, 2017
May 31, 2018
Mar 24, 2020
Mar 24, 2020

Repository files navigation

http-rest

ajax / http wrapper for browser and node that allows config inheritance ( uses fetch API when present )

ᴋɪʟᴛ ᴊs npm Build Status GitHub license

Installation

Node module

npm install @kilt/http --save
var $http = require('http-rest');

Browser using node bundler

var $http = require('http-rest/browser');

// if you want to use fetch API when present
var $http = require('http-rest/fetch');

Browser using bower

bower install http-rest --save
// if you want to use fetch API when present (in bower.json)
// ...
"overrides": {
  "http-rest": {
    "main": "dist/fetch.js"
  }
},
// ...

Usage

// GET .../items?prop1=value1
$http.get('/items', { params: { prop1: value1 } });

$http.post('/items', {
  sample: 'payload'
});

$http.put('/items/:itemId', {
  sample: 'payload'
});

$http.patch('/items/:itemId', {
  sample: 'payload'
});

$http.delete('/items/:itemId');

Base configurations

var http_items = $http.base('items');

http_items.post({ prop1: 'value1' });

http_items.get(itemId);

http_items.put(itemId, {  prop1: 'another value' });

http_items.delete(itemId);

About

ajax/http wrapper for browser and node that allows config inheritance ( uses fetch API when present )

Resources

License

Stars

Watchers

Forks

Packages

No packages published