Here is the test.html
,I wrote:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>My Home Page</title>
</head>
<body>
<script src="test.js"></script>
</body>
</html>
Here is the test.js
:
fetch("example/data.txt").then(response => {
console.log(response.status);
console.log(response.headers.get("Content-Type"));
});
Here is the error I saved from Microsoft Edge:
test.js:1 Fetch API cannot load file:///C:/Users/pp/Github/Javascript_Work/testing/example/data.txt. URL scheme must be "http" or "https" for CORS request.
(anonymous) @ test.js:1
test.js:1 Uncaught (in promise) TypeError: Failed to fetch
at test.js:1
(anonymous) @ test.js:1
Promise.then (async)
(anonymous) @ test.js:1