score:1

Accepted answer

you expect object in your code however your api response is an array of objects. it's clearly visible from your logs.

to verify it you can simple try

setuser(result.data[0]); // instead of setuser(result.data);

this line below - always would result undefined values. since you are assigning an array, your variable destructuring like this would not work

const { firstname, lastname, collectorcode, financecompany } = user;

.

you might want to change the logic how to store user data since api response and current state does not really match.


Related Query

More Query from same tag