@feardread/feature-factory 1.1.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.min.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/factory/factory.js +6 -6
package/package.json
CHANGED
package/src/factory/factory.js
CHANGED
|
@@ -10,7 +10,7 @@ const StateFactory = (entity, data = null) => ({
|
|
|
10
10
|
|
|
11
11
|
const FeatureFactory = (sliceName, endpoint, options = {}) => {
|
|
12
12
|
const apiEndpoint = `${sliceName}/${endpoint}`;
|
|
13
|
-
const
|
|
13
|
+
const API = InstanceFactory({
|
|
14
14
|
API_BASE_URL: 'http://fear.master.com:4000/fear/api',
|
|
15
15
|
JWT_TOKEN: 'fear-x-token'
|
|
16
16
|
});
|
|
@@ -18,7 +18,7 @@ const FeatureFactory = (sliceName, endpoint, options = {}) => {
|
|
|
18
18
|
const fetch = createAsyncThunk(
|
|
19
19
|
apiEndpoint,
|
|
20
20
|
async (_, { rejectWithValue }) => {
|
|
21
|
-
return await
|
|
21
|
+
return await API.get(apiEndpoint)
|
|
22
22
|
.then((response) => {
|
|
23
23
|
if (response.data && response.data.success) {
|
|
24
24
|
return response.data.result;
|
|
@@ -34,7 +34,7 @@ const FeatureFactory = (sliceName, endpoint, options = {}) => {
|
|
|
34
34
|
const fetchOne = createAsyncThunk(
|
|
35
35
|
`${sliceName}/one`,
|
|
36
36
|
async (id, { rejectWithValue }) => {
|
|
37
|
-
return await
|
|
37
|
+
return await API.get(`${sliceName}/${id}`)
|
|
38
38
|
.then((response) => {
|
|
39
39
|
if (response.data && response.data.success) {
|
|
40
40
|
return response.data.result;
|
|
@@ -49,7 +49,7 @@ const FeatureFactory = (sliceName, endpoint, options = {}) => {
|
|
|
49
49
|
const search = createAsyncThunk(
|
|
50
50
|
`${sliceName}/search`,
|
|
51
51
|
async (query, { rejectWithValue }) => {
|
|
52
|
-
return await
|
|
52
|
+
return await API.get(`${sliceName}/search?${query}`)
|
|
53
53
|
.then((response) => {
|
|
54
54
|
if (response.data && response.data.success) {
|
|
55
55
|
return response.data.result;
|
|
@@ -63,7 +63,7 @@ const FeatureFactory = (sliceName, endpoint, options = {}) => {
|
|
|
63
63
|
|
|
64
64
|
const slice = createSlice({
|
|
65
65
|
sliceName,
|
|
66
|
-
initialState: StateFactory(sliceName,
|
|
66
|
+
initialState: StateFactory(sliceName, options.initialState || {}),
|
|
67
67
|
reducers: {
|
|
68
68
|
clearData: (state) => {
|
|
69
69
|
state[sliceName] = null;
|
|
@@ -116,7 +116,7 @@ const FeatureFactory = (sliceName, endpoint, options = {}) => {
|
|
|
116
116
|
return {
|
|
117
117
|
reducer: slice.reducer,
|
|
118
118
|
actions: slice.actions,
|
|
119
|
-
instance:
|
|
119
|
+
instance: API,
|
|
120
120
|
asyncActions: {
|
|
121
121
|
fetch,
|
|
122
122
|
fetchOne,
|