Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
haIIux wants to merge2 commits intokettanaito:main
base:main
Choose a base branch
Loading
fromhaIIux:get-to-fetch-suggestion

Conversation

@haIIux
Copy link

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:

You can useget when performing asynchronous operations as well:

asyncfunctiongetUser(id){constuser=awaitfetch(`/api/user/${id}`)returnuser}

The proposed change:

fetch

You can usefetch when performing asynchronous operations as well:

asyncfunctionfetchUser(id){constuser=awaitfetch(`/api/user/${id}`)returnuser}

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.

m9810223, hannibaldinski, YonatanHanan, cjbarth, niftykins, and VChet reacted with thumbs up emojiletstri reacted with thumbs down emoji
@haIIuxhaIIux changed the titleChange asynchronous to fetch suggestion.Change asynchronous get to fetch suggestion.Dec 14, 2022
You can use`get` when performing asynchronous operations as well:
###`fetch`

You can use`fetch` when performing asynchronous operations as well:

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.

mujeeb-kalwar reacted with thumbs up emoji
@haIIuxhaIIux requested a review fromcjbarthNovember 14, 2023 15:43
@cjbarth
Copy link

Why did you request my review since my previous comment is still open and unaddressed?

@haIIux
Copy link
Author

Why did you request my review since my previous comment is still open and unaddressed?

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
Copy link

I thingfetch should be in another cases.

get for returning value

constgetUser=()=>{returnfetch('/user').then(res=>res.json());};constuser=awaitgetUser();console.log(user);

fetch for fetching data to some variable

letuser;constfetchUser=async()=>{constres=awaitfetch('/user').then(res=>res.json());user=res;};awaitfetchUser();console.log(user);

@cjbarth
Copy link

@letstri , I'm not sure I follow your distinction betweenget andfetch here. Are you just saying thatget directly returns a value and thatfetch gets a value and then puts it "somewhere"?

@letstri
Copy link

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

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@cjbarthcjbarthAwaiting requested review from cjbarth

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@haIIux@cjbarth@letstri

[8]ページ先頭

©2009-2025 Movatter.jp