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

Add a 'followAndGet' method #479

Open
reda-alaoui opened this issue Jun 16, 2023 · 1 comment
Open

Add a 'followAndGet' method #479

reda-alaoui opened this issue Jun 16, 2023 · 1 comment

Comments

@reda-alaoui
Copy link
Contributor

Often, I need to use the following construct:

const username = (
  await (
    await this.ketting.follow('current-user')
  ).get()
).data.username;

I think it would be nice to have a shortcut like this:

const username = (
    await this.ketting.followAndGet('current-user')
).data.username;

What do you think? :)

@evert
Copy link
Collaborator

evert commented Jun 16, 2023

I've considered this, but probably the approach I would take is to add a .get() to FollowResource, so you could do:

this.ketting.follow('current-user').get()

The awkward thing here is (and also with your suggestion) is 'where does this stop'. Should we replicate the entire Resource api on FollowResource? Someone else might want put, head, post, etc.

So all of this is to say that, I agree that the API is a bit awkward for this and wish it weren't, but i'm not entirely sure what a good solution is that will work for more cases

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

No branches or pull requests

2 participants