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

207
Views
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 answers
Answer question

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 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!