Open belljames opened 3 years ago
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);
});
hi! When I run the ls command, I get a 404 error,
but when I copy the URL from the string and substitue the variables, I get the expected response:
I'm running via WSL on a fresh node.js install.
Any troublshooting tips appreciated!