1.0.3 • Published 6 years ago

redux-toolbox-fetch v1.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

redux-toolbox-fetch

npm version license

redux-toolbox-fetch works with React Redux and Redux Saga to send a HTTP request easily.

Installation

npm i redux-toolbox-fetch

Documentation

import { HttpRequestBuilder, ContentType, BodyParsers } from "redux-toolbox-fetch";

const getRequest = (content) => new HttpRequestBuilder()
        .setUrl("http://www.gov.hk/")
        .setAcceptType(ContentType.JSON)
        .setMethod(Method.POST)
        .setAuthorization("Bearer %%%香港IT收皮%%%")
        .setQuery(content)
        .toResult();

const postJSON = (content) => new HttpRequestBuilder()
        .setUrl("/your-path-json")
        .applyBodyParserMiddleware([BodyParsers.json])
        .setAcceptType(ContentType.JSON)
        .setContentType(ContentType.JSON)
        .setMethod(Method.POST)
        .setAuthorization("Bearer %%%香港IT收皮%%%")
        .setBody(content)
        .toResult();

const postFormUrlencoded = (content) => new HttpRequestBuilder()
        .setUrl("/your-path-x-www-form-urlencoded")
        .applyBodyParserMiddleware([BodyParsers.queryString])
        .setAcceptType(ContentType.JSON)
        .setContentType(ContentType.FormUrlencoded)
        .setMethod(Method.POST)
        .setAuthorization("Bearer %%%香港IT收皮%%%")
        .setBody({fuck: "world"})
        .toResult();

const getResponse = yield call(getRequest, {fuck: "world"}); // http://www.gov.hk/?fuck=world
const postJsonResponse = yield call(postJSON, {fuck: "world"});
const postFormUrlencodedResponse = yield call(postFormUrlencoded, {fuck: "world"});
  • 香港 IT 狗到此一遊
  • by Hong Kong IT dog 🐶
1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago