How to rewrite a PHP curl request in pure JS?

<?php
 $name = $_GET['name'];
 $phone = $_GET['phone'];
 $offer_id = '6'; 
 $api_key = 'fgf44d'; 
 $country_code = 'RO'; 
 $base_url = 'https://land1.ab'; 
 $price = '160'; 
 $referrer = 'super.com'; 
 $ip = $_SERVER['REMOTE_ADDR'];

 const API_URL = "https://api.adcombo.com/api/v2/order/create/";
 const API_KEY = "fgf44d";

 $isCurlEnabled = function(){
 return function_exists('curl_version');
};
 if (!$isCurlEnabled) {
 echo "<pre>";
 echo "pls install curl\n";
 echo "For *unix open terminal and type this:\n";
 echo 'sudo apt-get install curl && apt-get install php-curl';
die;
}

 $args = array(

 'api_key' => $api_key,
 'name' => $name,
 'phone' => $phone,
 'offer_id' => $offer_id,
 'country_code' => $country_code,
 'base_url' => $base_url,
 'price' => $price,
 'referrer' => $referrer,
 'ip' => $ip

);

 $url = API_URL.'?'.http_build_query($args);
 $curl = curl_init();
 curl_setopt_array($curl, array(
 CURLOPT_URL => $url,
 CURLOPT_RETURNTRANSFER => true
));
 curl_close($curl);

There is such php code. The name field and the phone went from form fields on the html site and were transferred to the page .php How to rewrite that in pure JS to insert in html as < script >?
March 19th 20 at 08:46
2 answers
March 19th 20 at 08:48
Better not do that in JS because of security reasons. You apparently have a API_KEY which must remain on the side of the backend.
March 19th 20 at 08:50
Js no cURL.

Find more questions by tags JavaScript