我正在使用eBay API进行关键字查找。我在https://robwu.nl/cors-anywhere.html测试了我的API字符串。我使用以下字符串进行测试:
,然后单击GET按钮,API返回有效的响应。
当我将API调用合并到提取中时,我无法获取响应数据。这是我正在执行的代码:
console.log(url);
const options = { method: 'GET' };
fetch( url, options)
.then(function(response) {
if (response.status >= 400)
{
console.log("eBay returned bad status of: ", response.status);
}
return false;
})
.then(function(myJson) {
console.log("second then");
if (myJson == undefined)
{
console.log("myJson = undefined");
document.getElementById("errorDiv").style.visibility = "visible";
document.getElementById("lblErrorText").innerHTML = "eBay was unable to find a match on " + decoded + ". That is the name our bar code service returned. If you want, you can try entering a different product name for eBay to try.";
}
else
{
console.log("then else");
//inspect the data that the WebAPI returned
console.log(myJson);
}
当我在控制台下查看开发人员工具时,我在日志中看到以下条目:
显示“ false”的日志条目是我希望能够检查API返回的数据的地方。
我想念什么?