title: JavaScript Error - Uncaught SyntaxError: Unexpected token {
body: <p>I am trying to use Chart JS in one of my laravel applications. </p>
  
  <p>I am pushing the data through the route and using json_encode($gross) to echo the gross of each order by day but I am getting the following error in my console log:</p>
  
  <p>Uncaught SyntaxError: Unexpected token {</p>
  
  <p>It references the the line of where I have used json_encode($gross). Anyone have any ideas why this is happening?</p>
  
  <pre><code>Here is the code coming through the controller:
  
  public function index()
  {   $wkRevenue = \App\Order::where('created_at', '&gt;=' , \Carbon\Carbon::now()-&gt;startOfMonth())-&gt;get();
      // dd($wkRevenue-&gt;pluck('created_at','gross'));
  
      return view('admin.dashboard')
              -&gt;with('created_at', $wkRevenue-&gt;pluck('created_at'))
              -&gt;with('grosss', $wkRevenue-&gt;pluck('gross'));
  }
  
  Here is the code in the js file:
  
  var data = {
      type:'line',
      labels:['Mon','Tues','Wed','Thurs','Fri','Sat','Sun'],
      datasets:[
      {
          data: {!! json_encode($gross) !!},
          backgroundColor:'rgba(137, 200, 85, 0.4)',
      }
  ]
  }
  var graph = document.getElementById('myNewChart').getContext('2d');
  var myNewChart = new Chart(graph ,{
  type: "line",
  data: data,
  options:{
      title:{
          display:true,
      }
  }
  }); 
  </code></pre>