Skip to content

Instantly share code, notes, and snippets.

@Daveiano
Created February 11, 2019 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Daveiano/3e2a8e0ff5d6da982cfcb1718f4a6415 to your computer and use it in GitHub Desktop.
Save Daveiano/3e2a8e0ff5d6da982cfcb1718f4a6415 to your computer and use it in GitHub Desktop.
Drupal 8 Request in php
<?php
try {
$response = \Drupal::httpClient()->get($_SERVER['HTTP_HOST'] . '/jsonapi/node/xxx');
$data = (string) $response->getBody();
if (empty($data)) {
return FALSE;
}
}
catch (RequestException $e) {
return FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment