Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

return false when I ping #15

Open
Jerry4013 opened this issue Jan 19, 2021 · 1 comment
Open

return false when I ping #15

Jerry4013 opened this issue Jan 19, 2021 · 1 comment

Comments

@Jerry4013
Copy link

Hi,
I installed this package to test the rest API of XRAY, but after I follow the README, when I try the "ping" API, I got a false instead a "pong". Could you please help with this issue? Thank you!

`import {XrayClient} from 'xray-client-js'

let xrayClient = new XrayClient({
serverUrl: 'myurl',
username: 'myusername',
password: 'mypassword!',
proxy: {host: 'myurl', port: 80, protocol: 'https'},
headers: { }
});

xrayClient.system().ping()
.then(result => {
console.log(result);
})
.catch(error => {
console.error(error);
});`

@yahavi
Copy link
Member

yahavi commented Jan 19, 2021

@Jerry4013,
Thanks for reporting this issue!

Pong returned only if the ping succeeded.
False returned when there was an error.
Here is the ping function: https://github.com/jfrog/xray-client-js/blob/master/src/SystemClient.ts#L10

try {
    return await this.httpClient.doRequest(requestParams);
} catch (error) {
    return false;
}

In order to support your use case and throw errors, we should remove the try-catch clause and modify the tests respectfully.
Would you like to contribute code that removing the try-catch?

By the way, you can find in the tests many examples for ping commands: https://github.com/jfrog/xray-client-js/blob/master/test/SystemClient.spec.ts#L28.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants