Laravel consuming API and transforming object to array

1

Next I'm making a request of type get and it's returning me a objeto and I'd like it to be an array, already tried to use

$dados= Array.of($response->getBody()->getContents());

But of the error! error

Parse error: syntax error, unexpected '.', expecting '('

MY CODES - >

web.api

use GuzzleHttp\Client;


Route::get('/', function () {


$client = new Client([
    // Base URI is used with relative requests
    'base_uri' => 'https://teste.herokuapp.com',
    // You can set any number of default request options.
    'timeout'  => 2.0,
]);
    $response = $client->request('GET', 'api/login');
    $dados= $response->getBody()->getContents();

    dd($dados);

   return view('posts.index', compact('dados'));
});

dd ($ data)

"{"contas":[{"id":7,"email":"[email protected]","senha":"4154512"},{"id":1,"email":"[email protected]","senha":"lucas123"},{"id":14,"email":"[email protected] "
    
asked by anonymous 10.03.2018 / 00:56

0 answers