A provider has an API that would be the following
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "xxxxx:yyyyyyy");
curl_setopt($ch, CURLOPT_URL, "https://xxxx.yyyy.com/api/clientes");
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
$retorno = curl_exec($ch);
$error = curl_errno($ch);
if ($error) {
echo "Error; " . $error;
} else {
curl_close($ch);
return $retorno;
}
the thing is that I can't access the data, and the provider doesn't support JS, it only supports PHP, in php it works fine for me, but what I want is to access the data directly through the front and simply show them.
I attach the code that I am running:
(async () => {
fetch("https://xxxx.dominio.com/api/clientes/1", {
mode: "cors",
method: "GET",
headers: {
Authorization: "Basic xxxxxx:yyyyyyyy",
},
})
.then((response) => response.json())
.then((json) => console.log(json));
})();