尝试使用 node.js 中的 jira-connector 库从 JIRA 中获取 json 问题列表
Trying to fetch json list of issues from JIRA using jira-connector library in node.js
如您所见,我正在使用 jira-connector 库连接到 JIRA,我试图以 JSON 格式显示数据,但我没有得到任何结果console.log(提供了一张图片)。
const JiraClient = require('jira-connector');
const jira = new JiraClient( {
host: 'URL',
basic_auth: {
username: 'username',
password: 'password'
}
});
jira.search.search(
{
jql: 'type = bug'
},
function(error, issue)
{
console.log(issue);
}
);
虽然您没有显示您的实际配置代码,但根据错误,我猜您正在传递一个字符串作为 host
键,但模块没有按您预期的方式解析。
从 npm documentation 上的示例来看,它们不只传递主机名(例如 host: 'jira.example.com'
副 host: 'http://jira.example.com'
。
从错误中可以看出,您可能忘记了 http
之后的冒号,或者他们不接受该协议,只需要主机名。
查看 source code,他们似乎没有尝试从主机名中解析协议,如果您想传递协议(例如 http),那是一个不同的配置选项。试试这个:
const jira = new JiraClient( {
host: 'hostname-without-http',
protocol: 'http', // defaults to https
basic_auth: {
username: 'username',
password: 'password'
}
});
如您所见,我正在使用 jira-connector 库连接到 JIRA,我试图以 JSON 格式显示数据,但我没有得到任何结果console.log(提供了一张图片)。
const JiraClient = require('jira-connector');
const jira = new JiraClient( {
host: 'URL',
basic_auth: {
username: 'username',
password: 'password'
}
});
jira.search.search(
{
jql: 'type = bug'
},
function(error, issue)
{
console.log(issue);
}
);
虽然您没有显示您的实际配置代码,但根据错误,我猜您正在传递一个字符串作为 host
键,但模块没有按您预期的方式解析。
从 npm documentation 上的示例来看,它们不只传递主机名(例如 host: 'jira.example.com'
副 host: 'http://jira.example.com'
。
从错误中可以看出,您可能忘记了 http
之后的冒号,或者他们不接受该协议,只需要主机名。
查看 source code,他们似乎没有尝试从主机名中解析协议,如果您想传递协议(例如 http),那是一个不同的配置选项。试试这个:
const jira = new JiraClient( {
host: 'hostname-without-http',
protocol: 'http', // defaults to https
basic_auth: {
username: 'username',
password: 'password'
}
});