eBay API不返回任何内容(我认为)

时间:2018-08-18 18:03:23

标签: fetch ebay-api

我正在使用eBay API进行关键字查找。我在https://robwu.nl/cors-anywhere.html测试了我的API字符串。我使用以下字符串进行测试:

  

http://svcs.ebay.com/services/search/FindingService/v1?OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=jonathan-wmjw-PRD-5262ede01-60b402b1&GLOBAL-ID=EBAY-US&RESPONSE-DATA-FORMAT=JSON&keywords=twix&paginationInput.entriesPerPage=3

,然后单击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);
                }

当我在控制台下查看开发人员工具时,我在日志中看到以下条目:

enter image description here

显示“ false”的日志条目是我希望能够检查API返回的数据的地方。

我想念什么?

0 个答案:

没有答案