-
-
Notifications
You must be signed in to change notification settings - Fork 346
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: add new client fetch
#1353
feat: add new client fetch
#1353
Conversation
the params are passed to the body. Is it intended? |
thanks. I'll check later 👍 |
Also code conflict might want to merge update. |
@soartec-lab it's what I use in my project if you need https://gist.github.com/anymaniax/44c1331a5643081a82da070e45f405f0 |
@anymaniax
This is by design. Referring to this, I interpret that the request parameters are to be specified in the body. |
e370e45
to
f546fc4
Compare
@soartec-lab If you pass the query params into the body it wont be a query params anymore or I am missing something? |
@anymaniax |
f546fc4
to
f8e5c55
Compare
packages/fetch/src/index.ts
Outdated
const normalizedParams = new URLSearchParams(); | ||
|
||
Object.entries(params || {}).forEach(([key, value]) => { | ||
if (value !== null && value !== undefined) { | ||
normalizedParams.append(key, value.toString()); | ||
} | ||
});` |
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.
normalize it by excluding undefined
and null
, because query params
join to fetch url
.
Hi, @anymaniax I took your advice into consideration and changed the Cloud you review again ? |
c2f96ac
to
47bfd13
Compare
cc654b3
to
ec07c15
Compare
@anymaniax I wanna add the |
Even if i merge this, I don't wanna close #1387, so I deleted |
No problem! We can always reopen if it accidentally closes. I always prefer to have PR linked to ticket so we can reference later. |
Thanks ! |
Status
READY
Description
Follow up for #1387
I added a new
fetch
client.Becouse, since the
fetch
API is mature, it has the advantage of reducing the bundle size of the application compared to usingAxios
, and I feel that this is sufficient in some cases.Furthermore, we think it can be used to select an HTTP client with
tanstack query
orswr
, or when calling an API from a server-side framework.In this PR, i implemented a client using the minimal
fetch
API. For example, customization by specifying mutator is not yet supported. However, I still think it is practical enough and would like to submmit it on first. I'll also submit a sample application in a subsequent PR.Ref: https://developer.mozilla.org/en-US/docs/Web/API/fetch
Related PRs
none
Todos
Steps to Test or Reproduce
I added a test case, so it should pass.