@fugood/mybigday-media-resource-api-redux
v0.4.1
Published
Redux wrapper for MyBigDay Media Resource API
Downloads
5
Keywords
Readme
mybigday-media-resource-api-redux
Redux wrapper for MyBigDay Media Resource API
Installation
$ npm i --save redux
$ npm i --save @fugood/mybigday-media-resource-api-redux
Usage
// get actions
import {
FileActions,
PhotoActions,
VideoActions,
BoxActions,
UploadPageActions,
} from '@fugood/mybigday-media-resource-api-redux/lib/actions';
// get HttpClient class
import { HttpClient } from '@fugood/mybigday-media-resource-api-redux/lib/utils';
const defaultReqHeaders = {
Authorization: 'Bearer <access_token>',
};
const client = new HttpClient('<server url here>', defaultReqHeaders);
// get middlewares
import { APICall } from '@fugood/mybigday-media-resource-api-redux/lib/middlewares';
// Make API middlewares
const middleware = APICall(client); // HttpClient
// get reducers
import {
file,
photo,
video,
box,
uploadPage,
} from '@fugood/mybigday-media-resource-api-redux/lib/reducers';
Change client defaultReqHeaders
import { HTTPClientActions } from '@fugood/mybigday-media-resource-api-redux/lib/actions';
const { setClientDefaultReqHeaders } = HTTPClientActions;
store.dispatch(setClientDefaultReqHeaders({
Authorization: 'Bearer <new access_token>',
}));