6.2 Fetch and Backed RapidAPI
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
// RapidAPI header https://rapidapi.com/spamakashrajtech/api/corona-virus-world-and-india-data
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://corona-virus-world-and-india-data.p.rapidapi.com/api"))
.header("x-rapidapi-key", "c1ebf686e7mshe4ed4400d544e06p107f7fjsn1235b397e8bd")
.header("x-rapidapi-host", "corona-virus-world-and-india-data.p.rapidapi.com")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
// RapidAPI request and response
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
// RapidAPI Body
System.out.println(response.body());