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

292
Views
ReactJS: function post axios error: is not a function

I have a form, and I'm trying to make a post.

In the form when it is submitted I call the saveEntity function:

import { createEntity } from './realmUser-reducer'

export interface IRealmUserUpdateProps extends StateProps, DispatchProps, RouteComponentProps<{ id: string }> { }

export const RealmUserUpdate = (props: IRealmUserUpdateProps) => {
interface LocationState {
    userId: number | string
}
const location = useLocation<LocationState>()

  const saveEntity = (event, errors, values) => {
     if (errors.length === 0) {
       const entity = {
         realm: {id: values.realm},
         user: {userId: location.state}
        }
       props.createEntity(entity)  // this error:  Uncaught (in promise) TypeError: props.createEntity is not a function
    }
   }


return(//.....)


const mapStateToProps = (storeState: IRootState) => (
    {
    });

const mapDispatchToProps = {
    createEntity
}


type StateProps = ReturnType<typeof mapStateToProps>;
type DispatchProps = typeof mapDispatchToProps;

export default connect(mapStateToProps, mapDispatchToProps)(RealmUserUpdate);

in my reducer:

export const createEntity: ICrudPutAction<IRealmUser> = entity => async dispatch => {
    const result = await dispatch({
        type: ACTION_TYPES.CREATE_REALMUSER,
        payload: axios.post(apiUrl, cleanEntity(entity)),
    });
    return result;
};

the model that I created:

export interface IRealmUser {
    id?: string | number | null;
    user?: {
        perCod?: any
    }
    realm?: {
        id?: number | string | null
    }
}

export const defaultValue: Readonly<IRealmUser> = {};

So my problem is that when I'm trying to do the post I receive an error:

the error: Uncaught (in promise) TypeError: props.createEntity is not a function

about the props.createEntity(entity)

EDIT1:

Adding console.log(props)

history: {
    "length": 50,
    "action": "PUSH",
    "location": {
        "pathname": "/realmUser/new",
        "state": 156001,
        "search": "",
        "hash": "",
        "key": "2dwfy5"
    }
}
location:{
    "pathname": "/realmUser/new",
    "state": 156001,
    "search": "",
    "hash": "",
    "key": "2dwfy5"
}
match: {
    "path": "/realmUser/new",
    "url": "/realmUser/new",
    "isExact": true,
    "params": {}
}
about 4 years ago · Juan Pablo Isaza
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!