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

How to create an url like /articles/:articleId/comments ? #2

Closed
christophehurpeau opened this issue Feb 27, 2019 · 3 comments
Closed

Comments

@christophehurpeau
Copy link
Contributor

Hello,

I'm struggling to understand the url builder.

It seems we can override the url when using singleRequest()
https://github.com/coinbase/rest-hooks/blob/master/src/resource/Resource.ts#L150
https://github.com/coinbase/rest-hooks/blob/master/src/resource/Resource.ts#L93-L99

But for listRequest, it's really limited:
https://github.com/coinbase/rest-hooks/blob/master/src/resource/Resource.ts#L167
https://github.com/coinbase/rest-hooks/blob/master/src/resource/Resource.ts#L111

Can you add a doc on how to build the url ?
Does a static method to build an url from params in the resource makes sense to you ?

Thank you,

@ntucker
Copy link
Collaborator

ntucker commented Feb 27, 2019

An example here: https://stackblitz.com/edit/rest-hooks?embed=1&file=resources/CommentResource.ts&hideExplorer=1&view=editor or a more complex case here https://stackblitz.com/edit/rest-hooks?embed=1&file=resources/IssueResource.tsx&view=editor

Basically you can use some of the members of searchParams to build the base url, and if you still want a querystring use the remaining to build that part of the url.

@christophehurpeau
Copy link
Contributor Author

Thank you :)

@ntucker
Copy link
Collaborator

ntucker commented Dec 6, 2022

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