jalendport / craft-fetch

Utilise the Guzzle HTTP client from within your Craft templates.
MIT License
24 stars 13 forks source link

Can't get HTML content of response body #1

Closed eablokker closed 6 years ago

eablokker commented 6 years ago

I want to use this plugin to fetch html content. Currently it passes the response body through a json_decode() function so it can only be used for fetching json data (this is not mentioned anywhere in the readme).

If I make the following modification to FetchTwigExtension.php then I can get the raw body response.

Would you consider making json decode optional?

$response = $client->request($method, $destination, $request);

$body = $response->getBody();

return [
    'statusCode' => $response->getStatusCode(),
    'reason' => $response->getReasonPhrase(),
    'body' => $body->getContents()
];