Skip to content
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

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

feat: replace axios with node-fetch #80

wants to merge 18 commits into from

Conversation

tannerbaum
Copy link
Contributor

No description provided.

@@ -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
Copy link
Contributor Author

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

@tannerbaum
Copy link
Contributor Author

@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.

Copy link
Member

@jhnns jhnns left a 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.

src/lib/api.ts Outdated Show resolved Hide resolved
}

request.headers["X-Requested-With"] = "XMLHttpRequest";
// defaults.withCredentials = true;
Copy link
Member

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).

src/lib/api.ts Outdated Show resolved Hide resolved
src/lib/api.ts Outdated Show resolved Hide resolved
@jhnns
Copy link
Member

jhnns commented Mar 11, 2022

@tannerbaum Let me know if you want me to review again :)

@tannerbaum tannerbaum marked this pull request as ready for review April 6, 2022 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants