Access SonarQube API with FetchAPI doesn't return any result

烂漫一生 提交于 2020-01-06 05:03:45

问题


I am trying to access SonarQube API through Fetch but it doesn't seem to be responding with any results. It just resolves with an opaque token.

Let me share what I have done so far:

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);
            });

I am setting the mode as no-cors as it was throwing ACAO errors.

The same URL works perfect when openend from chrome or inspected through Postman.

This is what I get when the promise resolves:

Below is the error that I get from the catch clause:

SyntaxError: Unexpected end of input
    at fetch.then.res (index.html:51)

来源:https://stackoverflow.com/questions/50577479/access-sonarqube-api-with-fetchapi-doesnt-return-any-result

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!