How to Retrieve Data from RapidAPI to a WordPress Website

I am attempting to retrieve information using the following API endpoint:

https://rapidapi.com/apilayernet/api/rest-countries-v1?endpoint=53aa5a08e4b0a705fcc323a6

While I’ve utilized wp_remote_get() for the request, I’m consistently encountering an error message instead of any data displayed:

 The site is experiencing technical difficulties.

For clarity, I’ve set up my composer.json file in the correct location within XAMPP and included the necessary library:

{
    "require-dev": {
        "mashape/unirest-php": "3.*"
    }
}

Additionally, I incorporated the API key in my code, but it seems to be malfunctioning:

$request = wp_remote_get( 'https://restcountries-v1.p.rapidapi.com/all', 
array(
"X-RapidAPI-Host" => "restcountries-v1.p.rapidapi.com",
"X-RapidAPI-Key" => "7fc872eb0bmsh1baf0c288235a1ep114aecjsn18f888f020c0"
 ) );
if( is_wp_error( $request ) ) {
return false; // Exit early
}
$body = wp_remote_retrieve_body( $request );
$data = json_decode( $body );
echo $data;

What can I do to resolve this problem and successfully fetch data?