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

345
Views
"Es posible que las acciones no tengan una propiedad de "tipo" indefinida. ¿Ha escrito mal una constante?"

Estoy desarrollando una aplicación de Facebook y estoy usando dos módulos diferentes: AdonisJS y react-redux-starter-kit . Entonces tengo una acción para almacenar un usuario que ha iniciado sesión con el botón de inicio de sesión de Facebook cuando se ejecuta la función de devolución de llamada:

 callback = (r) => { const { addLinkedAccount } = this.props addLinkedAccount({ userId: r.userId, name: r.name, accessToken: r.accessToken, email: r.email }) }

Y todo el archivo de acción:

 import { CALL_API } from 'redux-api-middleware' // ------------------------------------ // Constants // ------------------------------------ export const ADD_LINKED_ACCOUNT = 'linkedAccount:add_linked_account' export const ADD_LINKED_ACCOUNT_SUCCESS = 'linkedAccount:add_linked_account_success' export const ADD_LINKED_ACCOUNT_FAIL = 'linkedAccount:add_linked_account_fail' // ------------------------------------ // Actions // ------------------------------------ export function addLinkedAccount ({ userId, name, accessToken, email }) { return { [CALL_API]: { endpoint: '/api/linked-accounts', method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: JSON.stringify({ userId, name, accessToken, email }), types: [ADD_LINKED_ACCOUNT, ADD_LINKED_ACCOUNT_SUCCESS, ADD_LINKED_ACCOUNT_FAIL] } } } export const actions = { addLinkedAccount } // ------------------------------------ // Action Handlers // ------------------------------------ const ACTION_HANDLERS = { [ADD_LINKED_ACCOUNT]: state => ({ ...state, addingLinkedAccount: true }), [ADD_LINKED_ACCOUNT_SUCCESS]: (state, action) => ({ ...state, addingLinkedAccount: false, addLinkedAccountSuccess: true, linkedAccount: action.payload }), [ADD_LINKED_ACCOUNT_FAIL]: (state, action) => ({ ...state, addingLinkedAccount: false, addLinkedAccountError: action.payload.response.error }) } // ------------------------------------ // Reducer // ------------------------------------ const initialState = { addingLinkedAccount: false, addLinkedAccountSuccess: false, linkedAccount: null, addLinkedAccountError: {} } export default function linkedAccountReducer (state = initialState, action) { const handler = ACTION_HANDLERS[action.type] return handler ? handler(state, action) : state }

Cuando se ejecuta la callback de llamada, el mensaje de error en la consola:

Error no detectado: es posible que las acciones no tengan una propiedad de "tipo" indefinida. ¿Has escrito mal una constante?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La acción devuelta por addLinkedAccount de hecho no tiene un campo de type , sin embargo, al leer la documentación de redux-api-middleware , parece que así es exactamente como se supone que debe construirse la acción.

Supongo que no ha instalado el middleware en su tienda. Como se describe en la documentación del middleware, debe crear su tienda de la siguiente manera:

 import { createStore, applyMiddleware, combineReducers } from 'redux'; import { apiMiddleware } from 'redux-api-middleware'; import reducers from './reducers'; const reducer = combineReducers(reducers); // the next line is the important part const createStoreWithMiddleware = applyMiddleware(apiMiddleware)(createStore); export default function configureStore(initialState) { return createStoreWithMiddleware(reducer, initialState); }
over 4 years ago · Santiago Trujillo 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!