ls yields 404 (Not Found)
belljames opened this issue · 1 comments
belljames commented
kymikoloco commented
Auth is working correctly, but the version on NPM is not the same as main right now. There are slightly more issues with this particular code with the latest Jira REST API, so I changed it to use version 2
Also one of the then
calls is on the wrong object.
---
+++
@@ jira.js @@
loadWorklogs: async (days = 7, issueId) => {
return conf
.getAuth()
.then((auth) => {
return got(
- `https://${auth.domain}.atlassian.net/rest/api/3/issue/${issueId}/worklog`,
+ `https://${auth.domain}.atlassian.net/rest/api/2/issue/${issueId}/worklog`,
{
auth: `${auth.email}:${auth.token}`,
- json: true,
+ responseType: 'json',
query: {
- startedAfter: moment().subtract(days, "days").toISOString(),
+ startedAfter: moment().subtract(days, "days").valueOf(),
},
- }
- );
- })
- .then((response) => {
- return response.body;
+ })
+ .then((response) => JSON.parse(response.body))
+ .catch(err => console.error(err));;
});
},
---
+++
@@ worklog.js @@
},
(argv) => {
jira
.loadWorklogs(argv.days, argv.issue)
.then((logs) => {
console.log(
- logs.reduce((str, log) => {
+ logs.worklogs.reduce((str, log) => {
return (
str +
- `${log.issue.key}\t${moment
+ `${argv.issue}\t${moment
.duration(log.timeSpentSeconds, "seconds")
.format("hh:mm", { trim: false })}\t${log.comment}\n\r`
);
- }, `Total logs: ${logs.length}\n\r`)
+ }, `Total logs: ${logs.worklogs.length}\n\r`)
);
})
.catch((e) => {
console.error(e.toString());
process.exit(1);
});