-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: replace axios with node-fetch #80
base: main
Are you sure you want to change the base?
Conversation
@@ -85,18 +90,24 @@ export class Api { | |||
this.config({ client, authentication, baseUrl }); | |||
} | |||
|
|||
// The fact that this can be called again was a source of great confusion. I had changed the if below to throw if (!baseUrl || typeof baseUrl !== "string"), but turns out sometimes we don't need it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this comment later lol
@jhnns I think I might need to see that function you mentioned in the Clockodo project for detecting error message content , but in general feedback would be appreciated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general: Looks good 👍 that's definitely the right direction. I've added some minor comments.
} | ||
|
||
request.headers["X-Requested-With"] = "XMLHttpRequest"; | ||
// defaults.withCredentials = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something we need to preserve. The regular SDK authentication is done via API key. However, at Clockodo itself, we sometimes need to do cookie auth instead. That's why we need to send cookies along each request once authentication
has been set to undefined
.
Using the fetch()
API, this is done by setting credentials: "include"
(see https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials)
Looking back I think this config could be improved in the way that authentication
is set explicitly to "cookie"
(makes it more obvious). If you want, you can change that :) (since this is a breaking change, we need to include it in the changelog).
@tannerbaum Let me know if you want me to review again :) |
No description provided.