php - My request with GuzzleHttp stagnates -
hi trying consume api guzzlehttp stagnates.(loading infinite in browser)
technologies:
- laravel 5.2
- guzzlehttp 6.0
usercontroller.php
<?php namespace app\http\controllers; use app\user; use illuminate\http\request; use app\http\requests; use illuminate\support\facades\input; use guzzlehttp\client guzzlehttpclient; use guzzlehttp\exception\requestexception; public function index() { try { $client = new guzzlehttpclient(); $apirequest = $client->request('get', 'localhost:8000/api'); $content = json_decode($apirequest->getbody()->getcontents()); dd($content); } catch (requestexception $re) { dd($re); } } }
note: when test postman, ok.
what think
i sure problem is:
$apirequest = $client->request('get', 'localhost:8000/api');
but don't know why.
maybe data important web running in localhost(because don't know if there interference if have web , , api in same web):
localhost:8000/home
routes.php
<?php route::get('/', function () { return view('auth/login'); }); route::auth(); route::get('home', 'usercontroller@index'); route::resource('api', 'apicontroller');
any suggestions?
Comments
Post a Comment