需要检查 API 调用中使用的认证标识是否正确。可以按照以下步骤进行排查:
代码示例:
// 使用 API 密钥认证方式调用 API const apiKey = "YOUR_API_KEY"; const apiSecret = "YOUR_API_SECRET";
// 构造请求头
const headers = {
"Content-Type": "application/json",
"Authorization": Api-Key ${apiKey}:${apiSecret}
};
// 发送 API 请求 fetch("https://api.etim.com/v1", { method: "GET", headers: headers }) .then(response => response.json()) .then(data => console.log(data)) .catch(error => console.error(error));