Bhargav960143
9 months ago

Guzzle Get Request Loading

Posted 9 months ago by Bhargav960143

Guzzle version(s) affected: "guzzlehttp/guzzle": "^6.3", PHP Version:"7.2.10",

Client {#827 ▼
  -config: array:7 [▼
    "verify" => false
    "handler" => HandlerStack {#829 ▶}
    "allow_redirects" => array:5 [▶]
    "http_errors" => true
    "decode_content" => true
    "cookies" => false
    "headers" => array:1 [▼
      "User-Agent" => "GuzzleHttp/6.3.3 curl/7.61.1 PHP/7.3.0"
    ]
  ]
}

Description When I call get request it's loading nothing display.

How to reproduce My Front End Controller:

PostController.php

namespace App\Http\Controllers\Frontend;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp;

class PostController extends Controller
{
public function index()
    {
$client = new GuzzleHttp\Client();
        $res = $client->request('GET', url('api') . '/post_data');
        echo $res->getStatusCode();
        exit;
}
}

My API Route

Route::get('post_data',  'API\[email protected]_post');

My API Post Controller

namespace App\Http\Controllers\API;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\Request;
use App\Post;
use Validator;

class PostController extends Controller
{
    public $successStatus = 200;
    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {

    }
    /*
     * Home page Post api
     */
    public function get_post(){
        $post = Post::select('name','slug')->where("display_home","=","1")->orderBy('id', 'desc')->skip(0)->take(3)->get();
        return response()->json(['success' =>$post], $this-> successStatus);
    }
}

My Web Route

Route::get('/', 'Frontend\[email protected]');

Please sign in or create an account to participate in this conversation.