4

After an update, if the status code was an 422 i have a notification with this message : Cannot read property 'hasOwnProperty' of undefined

    TypeError: Cannot read property 'hasOwnProperty' of undefined
    at validateResponseFormat (http://localhost:4100/static/js/0.chunk.js:147058:17)
    at http://localhost:4100/static/js/0.chunk.js:147133:43
    at step (http://localhost:4100/static/js/0.chunk.js:147018:19)
    at Object.next (http://localhost:4100/static/js/0.chunk.js:146948:14)
    at next (http://localhost:4100/static/js/0.chunk.js:227925:27)
    at currCb (http://localhost:4100/static/js/0.chunk.js:228012:7)

And my api is sending this reponse :


    {
        "error": {
            "details": [{
                    "status": "week",
                    "message": "",
                    "target": "ModelState"
                }
            ],
            "innerError": null,
            "status": "422",
            "message": "Invalid model",
            "target": "ModelState"
        }
    }

sorcer1
  • 117
  • 3
  • 11

1 Answers1

1

I had this error minutes ago and found your question with no answers. It could be related with dataProvider.js.

In my case, I solved it editing the type case (GET_LIST, GET_ONE, UPDATE, etc.) into the switch. I made a data mapping into the type, specifying the resource from which I am receiving the data. Better see the code below:

// dataProvider.js

...

switch(type){
    case GET_ONE:{
        if (resource === 'users'){
            return {
                data: {
                    id: json.id,
                    email: json.email,
                    isAdmin: json.isAdmin,
                    password: json.password
                }
            }
        }

...

}

As a disclaimer, I am quite new to React-Admin and React. But I hope this answer to be helpful to somebody who finds this question.

oz19
  • 1,616
  • 1
  • 17
  • 22