in a little laravel application I'm working on I'm returning data from an ajax request like this:
return response ()->json ( $subject::where('id', $subject->id)->with('division')->get(['id', 'name']));
This returned something quite like an object that have nested objects. This how my results looks when I log it to the console.
I want to get the name and id of the subject details returned, which in this case is History and 8. Also I want to be able to access the division array and properties of the object it has.
I do this to log the name of the subject console.log(data.name)
but in returned I get:
undefined
How can I achieve this?