/restful-service

A restful service using native fetch

Primary LanguageJavaScriptMIT LicenseMIT

Restful-Service

License

Restful service is HTTP adapter for the front-end using native window fetch for making network calls

Installation

Install the dependencies and devDependencies and start the server.

$ npm install restful-service
or
$ yarn add restful-service

Usage

import { restGet, restPost } from 'restful-service';

const promise = restGet(urlString)();
promise.then(result => console.log(result));
    
const res = restPost(urlString)(payloadObject)();
res.then(r => console.log(r))

Examples

Get Request:
import { restGet, restPost } from 'restful-service';

const promise = restGet('https://jsonplaceholder.typicode.com/users')()
promise.then(result => console.log(result))
Post Request:
const promise = restPost('https://jsonplaceholder.typicode.com/posts')({
  title: 'foo',
  body: 'bar',
  userId: 1
})();
promise.then(result => console.log(result))