I have been trying to debug this error for a while now. I tried scouring the internet for solutions, yet I still can't find the fix for it. I am passing the required data for the API to work, but the error is still there.
Laravel Controller
protected function searchAdmin(Request $request)
{
$data = $request->validate([
'admin_ref' => 'string|required'
]);
$admin = adminInfos::where('adminID', $data['admin_ref'])->first();
if (!$admin) {
return response()->json([
'status' => '404',
'message' => $this->response['AccntNtFnd']
]);
} else {
return response()->json([
'status' => '200',
'account' => $admin
]);
}
}
React JS
const searchAdmin = (e) =>{
e.preventDefault();
axios.get(`http://127.0.0.1:8001/api/admin/adminSearch`, {
'headers':{
'Accept':'application/json',
'Content-Type':'application/json',
},
'data':{
'admin_ref': adminInput.searchInput
}
}).then(res=>{
if(res.data.status != 200){
console.log(res.data.message)
}else{
console.log(res.data.message)
}
}).catch(error => {
console.log(error.response.data)
});
}
UPDATE: I followed Nelson's advice, but the error still exists. Thank you for the advice tho, will make sure to take note of it.