[英]Object won't return in console
我试图在本地主机上运行我的 API,但是当我输入npm run dev 时,终端会显示此错误消息。
7 | <title>MULTIPLE APIs</title>
8 | </head>
9 | <body>
| ^
10 | <body class="bg-gray-100">
11 | <h1 class= "text-bold text-6xl text center p-
8">Multiple API Feed</h1>
当我查看 Chrome Dev 控制台时,它显示crbug/1173575,不推荐使用非 JS 模块文件。 (匿名)@(索引):7290
[vite] Internal server error: Unable to parse {"file":"/index.html","line":9,"column":3}
下面是我的 index.html 文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml"
href="favicon.svg" />
<meta name="viewport" content="width=device-width,
initial-scale=1.0" />
<title>MULTIPLE APIs</title>
</head>
<body>
<body class="bg-gray-100">
<h1 class= "text-bold text-6xl text center p-
8">Multiple API Feed</h1>
<div id ="app" class="min-h-screen flex flex-col
justify-center items-center gap-2"></div>
<script type="module" src="/main.js"></script>
</body>
</html>
这是我的 main.js 文件
import './style.css';
const RAPIDAPI_KEY = import.meta.env.VITE_RAPIDAPI_KEY;
const LOVECALCULATOR_URL =
'https://love-
calculator.p.rapidapi.com/getPercentage';
const LOVECALCULATOR_HOST = 'love-
calculator.p.rapidapi.com';
const getData = async (url, host) => {
const response = await fetch(url, {
method: 'GET',
headers: {
accept: 'application/json',
'x-rapidapi-key': RAPIDAPI_KEY,
'x-rapidapi-host': host,
},
});
if (!response.ok) {
throw new Error(`HTTP error! status:
${response.status}`);
}
return await response.json();
};
const runApiQueries = async () => {
//GET MATCHMAKER RESULTS
const loveData = await getData(LOVECALCULATOR_URL,
LOVECALCULATOR_HOST);
console.log(loveData);
};
runApiQueries();
我相信有重复的body
标签会导致问题。 请检查第 9 行和第 10 行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.