0

I'm creating a Laravel project and trying to display a HTML response in a GET API.

My goal is when a user clicks the button / href, a new tab will open and he/she will be redirected to the HTML response from the GET API.

Here's my sample Guzzle HTTP

    $client_two    = new \GuzzleHttp\Client();
    $payload_two   = $client_two->request('GET','sample url' ,[
        'auth'     => ['test', 'key'],
        'headers'  => ['content-type' => 'application/json', 'Accept' => '*'],
        'query' => [
            'user_id' => $details['user_id'],
            'login_auth_key' => $details['login_auth_key']
        ]
    ]);

Here's a snippet of the HTML response from POSTMAN

<!DOCTYPE html>
<html lang="en">
<head>
<title> HomePage </title>
</head>
<body>
    <div id="pageLoader" style="display: none;">
        <div class="connectLoader">
            <span>
                Connecting...
            </span>
        </div>
    </div>
    <div id="header-logo">
         <a href="#" class="logo-content-big" title="Multiline Verve">
                <i>Multiline</i>
                <span>Contact Multiline</span>
         </a>
    </div>
</body>
</html>

Any suggestions on how to do this?

  • 2
    How about you make a second page like (response.html) and when the user clicks on the button your API Response gets loaded when your page loads. You can use `` to load your API on the opening of a new window. – Maybe Aug 26 '21 at 07:04
  • The GET request can also be used directly in the URL of the new tab.. I guess you want to hide the true URL? – Peter Krebs Aug 26 '21 at 07:31

1 Answers1

0

So, I tried both of the advises of @Peter Krebs and @Maybe from the comments.

Both work however in the end, I just called the GET request URL directly in a href tag.

Here's a sample I used.

<a href="https://test/agent?1234556" target="_blank">CHECK</a>

Thanks.