Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

213
Vistas
My order action is not working `const { data } = await axios.post('/api/v1/order/new', order, config)` returns error code 500 internal server error

This is the orderActions.js

console.log('test1');

export const createOrder = (order) => async (dispatch, getState) => {
    try {
console.log('test2');
        dispatch({ type: CREATE_ORDER_REQUEST })
        console.log('test3');
        const config = {
            headers: {
                'Content-Type': 'application/json'
            }
        }
        console.log('test4');
        const { data } = await axios.post('/api/v1/order/new', order, config)

        dispatch({
            type: CREATE_ORDER_SUCCESS,
            payload: data
        })
        console.log('test5');
    } catch (error) {
        dispatch({
            type: CREATE_ORDER_FAIL,
            payload: error.response.data.message
        })
        console.log('test55', error);
    }
}

console.log('test6', createOrder);

My console.log shows

test1

test6 order => async (dispatch, getState) => {.....}

test2

test3

test4

but test5 doesnt show and i cant create a new order for my products

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think you need to await createOrder in log6. And you need to call createOrder as a function and pass in the order.

console.log('test6', await createOrder(anOrder))

Except, you say you get a 500 internal server error? Not sure how that's happening...

And shouldn't the method signature be like this?

export const createOrder = async (order, dispatch, getState) => {

Maybe I'm skimming the code too quickly...

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda