Access SonarQube API with FetchAPI doesn't ret

2019-08-23 06:32发布

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: enter image description here

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

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

0条回答
登录 后发表回答