Question:
When I make a http req with fetch in javaScript
Get This Error In console
test.ulvhgujdfd14.repl.co/:1 Access to fetch at 'https://api.binance.com/api/v3/userDataStream' from origin 'https://test.ulvhgujdfd14.repl.co' has been blocked by CORS policy: Request header field x-mbx-apikey is not allowed by Access-Control-Allow-Headers in preflight response.
(index):24 POST https://api.binance.com/api/v3/userDataStream net::ERR_FAILED
(anonymous) @ (index):24
(index):27 error TypeError: Failed to fetch
at (index):24:5
Console Screen:
Network Screen:
Repl link:
https://replit.com/@ulvhgujdfd14/TEST
My Html & JS Code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
var myHeaders = new Headers();
myHeaders.append(
"X-MBX-APIKEY",
"My API HERE"
);
myHeaders.append(
"Content-Type", "text/plain"
);
var requestOptions = {
method: "POST",
headers: myHeaders,
};
fetch("https://api.binance.com/api/v3/userDataStream", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
</script>
</body>
</html>
Please Help