1.0.1 • Published 7 years ago

@idan-loo/request-json v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
7 years ago

Request JSON

Intro

A http request library for Restful API. All the responses will be parsed as json objects.

Install

npm install --save @idan-loo/request-json

Example

import request from '@idan-loo/request-json';

request.get('./test.json', {name: 'tom'})
    .then(result => /* do something with result */);

Notice

You should give a fetch function in most case.

import request from '@idan-loo/request-json';
import fetch from 'isomorphic-fetch';

request.setFetch(fetch);

request.get(/* do something */);

API

get(uri: string, query?: Object): Promise<any>;
post(uri: string, body: any): Promise<any>;
put(uri: string, body: any): Promise<any>;
delete(uri: string, query?: any): Promise<any>;