I am having this error from my code. I am trying to get the weekly timed summary from each user in a clockify workspace. I am getting an error:
Error: Request failed with status code 404
at createError (/Users//Desktop/Dev/dotClock/node_modules/axios/lib/core/createError.js:16:15)
at settle (/Users//Desktop/Dev/dotClock/node_modules/axios/lib/core/settle.js:17:12)
at IncomingMessage.handleStreamEnd (/Users//Desktop/Dev/dotClock/node_modules/axios/lib/adapters/http.js:260:11)
at IncomingMessage.emit (events.js:327:22)
at endReadableNT (internal/streams/readable.js:1327:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15042) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:15042) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I did use the example code to get going, then will make changes as needed. My code does not work, and according to the documentation it should. Here is the code:
const axios = require('axios')
const key = process.env.CLOCKIFY_API_KEY || 'KEY'
const url = `https://reports.api.clockify.me/v1`
if (!key) {
console.log(`API key must be provided through 'CLOCKIFY_API_KEY' env variable. Get one at https://clockify.me/user/settings`)
process.exit(1)
};
(async () => {
const axiosResponse = await axios.post(`${url}/workspaces/id/reports/weekly`, {
headers: {
'X-Api-Key': key
}
})
console.log(axiosResponse)
})()
Please help me with this as I have been struggling and new with APIs.