Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

399
Views
¿Cómo obtener la variable del controlador en el archivo blade? Laravel 8

Estoy tratando de obtener el retorno ($orders_box) de una función en mi controlador en mi archivo blade javascript para poder mostrarlo en una tabla en mi archivo blade.

En este momento, el código de la hoja se ve así:

 function checkOrderId () { const orderID = document.getElementById('PolarisTextField2').value; const response = localStorage.getItem('orders_box'); fetch('/checkBalanceRoute/' + orderID) .then(response => console.log(response)) }

y el código del controlador se ve así:

 { public function checkBalance ($orderID){ $shop = Auth::user(); $req = $shop->api()->rest('GET', "/admin/api/2022-04/orders/$orderID.json"); $orders = $req['body']['orders']; $orders_box = []; foreach ($orders as $order) { $data = array( 'Order Id' => $order->id, 'Total Price' => $order->total_price, 'Name' => $order->billing_address->name, ); array_push($orders_box, $data); } return response() ->json([ 'success' => true, 'order_box' => $orders_box ], 200); }

¿Alguna idea?

Agradezco la ayuda.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

En lugar de print_r($orders_box); usar

 return response()->json([ 'success' => true, 'order_box' => $order_box ], 200);

Esto devolverá una respuesta a su API.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!