Skip to content
Advertisement

How to show array data form controller in blade file (html table)? Laravel

Since I am completely new in Laravel, I have a problem pretty complicated for me.

I have controller file ApiHandlerController like this:

JavaScript

myview.blade.php as a view file:

JavaScript

And web.php file with route:

JavaScript

My question is:

How to show result of todos from jsonplaceholder.typicode.com in this blade (view) file? Currently, it’s not possible, and every time I try this is an error:

ErrorException Undefined variable: arr_body (View: C:xampphtdocsTodoListresourcesviewsmyview.blade.php) Thank you guys in advance!

Advertisement

Answer

To show array type data in blade…

First edit your controller code.

From:

JavaScript

To:

JavaScript

Below is core php syntex.

JavaScript

Laravel syntex

JavaScript

Hope this will be useful.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement