Skip to content

Fiju/restful-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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))

About

A restful service using native fetch

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published