Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

766
Views
Error: las acciones deben ser objetos simples. Use middleware personalizado para acciones asíncronas. Kit de herramientas Redux

Tengo el siguiente código con redux-toolkit pero no puedo encontrar el error

 if (token) { // this code dispatches the function below in a different file const data = { service: 'stripe', stripe_payment_id: token.id, }; dispatch(setPaymentMethod({ data, tenantId: tenant.id })); } export const setPaymentMethod = (params: any) => { const { data, tenantId } = params; return async (dispatch: any, getState: any) => dispatch( postRequest( `${API.TENANTS}/${tenantId}/${API.PAYMENT_METHODS}`, data, response => console.log(response), ), ); };

El código anterior llama al archivo del controlador API de esta manera

 const postRequest = async ( url: string, body: any, onSuccess: (x: any) => void, onError?: () => void, params?: any, ) => { return async (dispatch: any, getState: any) => { try { let response = await API.post(url, body, {}); if (response.status === 200) { console.log(response); onSuccess(response.data); } } catch (error) { console.log(error); } }; };

Tal vez no estoy viendo el error y parece fácil de solucionar, pero no he encontrado la solución, ¡ayuda por favor!

Estoy usando redux-toolkit que ya usa redux-thunk detrás de escena

/Almacenar configuración

 const rootReducer = combineReducers({ /* PLOP_INJECT_EXPORT */ tenantsReducer: tenantsSlice, receiptsReducer: receiptsSlice, geoLocationReducer: geoLocationSlice, storesReducer: storesSlice, authReducer: authSlice, exampleReducer: exampleSlice, uiReducer: uiSlice, tokensReducer: tokensSlice, [usersApi.reducerPath]: usersApi.reducer, }); const persistConfig = { key: 'root', version: 1, storage: AsyncStorage, // whitelist: ['uiReducer'], }; const persistedReducer = persistReducer(persistConfig, rootReducer); const store = configureStore({ reducer: persistedReducer, middleware: getDefaultMiddleware => getDefaultMiddleware({ serializableCheck: { ignoredActions: [FLUSH, REHYDRATE, PAUSE, PERSIST, PURGE, REGISTER], }, }), }); setupListeners(store.dispatch);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Redux-Thunk no maneja promesas fuera del libro. Compruebe createAsyncThunk .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!