Axios 'get' request returns an empty object response when I pass the route to retrieve JSON object
I want to retrieve JSON data from my registration controller but gets an empty response
this is my registration controller
public function show($id)
{
$registration =
$this->registrationRepository->findRegistrationById($id);
return response()->json($registration);
}
this is my script
export default {
props:{
studentid:Number,
registrationid:Number,
},
data(){
return {
registration:{}
}
},
created(){
this.loadRegisteredSubjects();
},
methods: {
loadRegisteredSubjects(){
axios.get('/admin/registrations/'+this.registrationid+'/show')
.then(response => (this.registration = response)
}
}
}
when I passed the route from where to retrieve the data
http://127.0.0.1:8000/admin/registrations/13/show
i get the desire results which is
{"id":13,"student_id":2,"subjects":"3,4,5","created_at":"2019-10-01 01:13:13","updated_at":"2019-10-01 01:13:13"}
unfortunately, I get an empty registration object when I pass the same route to Axios
reponse, if so thisresponse.datawould error. Can you update the question with the actual code you are using?.then(response => { this.registration = response.data })