Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork926
Change asynchronous get to fetch suggestion.#83
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
| You can use`get` when performing asynchronous operations as well: | ||
| ###`fetch` | ||
| You can use`fetch` when performing asynchronous operations as well: |
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.
I don't think that "as well" is appropriate here since it isn't connected withget anymore.
cjbarth commentedNov 15, 2023
Why did you request my review since my previous comment is still open and unaddressed? |
haIIux commentedNov 15, 2023
Appears actually to be an error with GitHub mobile. I had requested a review on a private repository. I'll address your requested changes asap! I apologize for the inconvenience. |
letstri commentedFeb 16, 2024
I thing
constgetUser=()=>{returnfetch('/user').then(res=>res.json());};constuser=awaitgetUser();console.log(user);
letuser;constfetchUser=async()=>{constres=awaitfetch('/user').then(res=>res.json());user=res;};awaitfetchUser();console.log(user); |
cjbarth commentedJul 22, 2025
@letstri , I'm not sure I follow your distinction between |
letstri commentedOct 29, 2025
@cjbarth Yes, exactly. It's more logical to me. It's like 'refetch' in TanStack Query. You won't get the value after the call "refetch". |
In the example displayed currently in the notes, it suggests that the asynchronous function would return instantaneously when it could return errors or throw. In my opinion, it would be better to recommend a namespace in which would reflect that accordingly.
The current example:
The proposed change:
The ideaology behind my suggestion is as follows. When you're playingfetch with a dog, the dog does not always immediately return. The dog may get distracted or while returning drop it before returning to the handler, thus erroring out and dropping the return.