代码之家  ›  专栏  ›  技术社区  ›  Aakash Thakur

使用FetchAPI访问Qube API不会返回任何结果

  •  0
  • Aakash Thakur  · 技术社区  · 6 年前

    我试图通过Fetch访问SonarQube API,但它似乎没有响应任何结果。它只是用一个不透明的标记进行解析。

    fetch("http://localhost:9000/api/issues/search?pageSize=500&componentKeys=bactch_analysis_key",{
                mode:'no-cors'
            }) // Call the fetch function passing the url of the API as a parameter
                .then(
                    res => res.json()
                )
                .then(data => {
                    console.log(data);
                })
                .catch(err =>  {
                    console.log(err);
                });
    

    我正在设置 mode no-cors 因为它正在抛出ACAO错误。

    当从chrome浏览器打开或通过邮递员检查时,相同的URL工作得非常完美。

    enter image description here

    下面是我从 catch

    SyntaxError: Unexpected end of input
        at fetch.then.res (index.html:51)
    
    0 回复  |  直到 6 年前