FIX;Rename api middleware
This commit is contained in:
parent
9c7a15a2db
commit
a36652326d
2 changed files with 4 additions and 4 deletions
|
@ -8,7 +8,7 @@ import { Router } from 'react-router';
|
|||
import config from '../../../app.config';
|
||||
|
||||
import { initLocalization } from '@romanjaros/treejs-localization/init';
|
||||
import { FetchEndpoint } from '@romanjaros/treejs-api/middleware';
|
||||
import { apiMiddleware } from '@romanjaros/treejs-api/middleware';
|
||||
import '@romanjaros/treejs-types/global';
|
||||
|
||||
import mainReducer from 'documentation/reducer';
|
||||
|
@ -29,7 +29,7 @@ const store = createStore(
|
|||
composeSetup(
|
||||
applyMiddleware(
|
||||
thunk,
|
||||
FetchEndpoint({
|
||||
apiMiddleware({
|
||||
BASE_ENDPOINT_URL: config.BASE_ENDPOINT_URL,
|
||||
})
|
||||
)
|
||||
|
|
|
@ -13,7 +13,7 @@ interface ISettings {
|
|||
BASE_ENDPOINT_URL: string;
|
||||
}
|
||||
|
||||
export const FetchEndpoint = (setting: ISettings): Middleware => (store) => (next) => async (
|
||||
export const apiMiddleware = (setting: ISettings): Middleware => (store) => (next) => async (
|
||||
action: IAction<IFetchConfig>
|
||||
) => {
|
||||
if (action.type === FetchActions.FETCH) {
|
||||
|
@ -43,7 +43,7 @@ export const FetchEndpoint = (setting: ISettings): Middleware => (store) => (nex
|
|||
store.dispatch(fetchStatusActions.onSuccess(action.payload));
|
||||
|
||||
const json = await response.text().then((text: string) => {
|
||||
return isJSON(text) ? JSON.parse(text) : {};
|
||||
return isJSON(text) ? JSON.parse(text) : text;
|
||||
});
|
||||
|
||||
if (is(Function, action.payload.onSuccess)) {
|
||||
|
|
Loading…
Add table
Reference in a new issue