This is my res.data.enquiry - object I'm getting from api call
{
active: true
createdAt: "2021-09-03T05:58:32.584Z"
ID: {category: Array(1),
Images: Array(5),
_id:'6131b96650a4b8127f7c59c8',
loginMethod: 0,
phone: '65565656', …}
messages: (4) [{…}, {…}, {…}, {…}]
__v: 3
_id: "COOK000000000036"
}
My UseState where I initialized the SingleEnq as an empty object to set it with res.data.enquiry during the fetch from api. (also tried null)
const [singleEnq, setSingleEnq] = useState({});
My fetch function
function getOneticket(userID) {
axios
.get(`admin/enquiry/get/one?enquiryID=${userID}`)
.then((res) => {
setSingleEnq(res.data.enquiry)
})
.catch((err) => {
console.log(err, "error message for get one ");
});
}
My useState remains empty. Dont know the reason. It's not setting up the data from the api.