I would like to assign an array from Laravel to a JavaScript array. I have gotten the array from my AppServiceProvider
and json_decoded it like:
View::composer('*', function($view)
{
$users = Users::all();
$view->with(compact(users );
}
I then access my $usersArray from my javascript file like:
var dataSet = JSON.parse({!!$users !!});
I am however getting the following error;
jQuery.Deferred exception: Unexpected token o in JSON at position 1 SyntaxError: Unexpected token o in JSON at position 1
at JSON.parse (<anonymous>)