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

Using a url property in a resource response #106

Closed
goncy opened this issue Jul 15, 2019 · 6 comments · Fixed by #107
Closed

Using a url property in a resource response #106

goncy opened this issue Jul 15, 2019 · 6 comments · Fixed by #107
Labels
bug Something isn't working

Comments

@goncy
Copy link
Contributor

goncy commented Jul 15, 2019

I get an error when the response of a resource contains a property named url

Reproduced here:
https://codesandbox.io/s/weathered-meadow-46fmn

Go to resource.js and uncomment the commented line.

I still didn't check why this could be happening but will try to take a look in these days

@goncy goncy added the bug Something isn't working label Jul 15, 2019
@ntucker
Copy link
Collaborator

ntucker commented Jul 15, 2019

Ah yes, the error thrown is "TypeError: setting getter-only property "url""

What's going on is there's a convenience getter that returns an items url. However, in cases where they have their own member it tries to set which doesn't work. I'll look into a fix for this.

@goncy
Copy link
Contributor Author

goncy commented Jul 16, 2019

Nice, i just went through this trying to do the "hello world" using the SWAPI api, was just unlucky with the response containing a url property, the example on the docs is awesome, but probably having an easier or less complex one would be nice to let the idea sink

@ntucker
Copy link
Collaborator

ntucker commented Jul 16, 2019

Are you referring to this example in the docs: https://resthooks.io/docs/guides/resource-types as being too complex? My plan is to create a really simple forum api to build a new demo with (the github api is quite complex so it makes first intro kinda overwhelming). Then I could probably change most of my examples to actually match the demo api and then you could just go into the demo page yourself. How does that sound?

@ntucker
Copy link
Collaborator

ntucker commented Jul 16, 2019

Fix released in https://github.com/coinbase/rest-hooks/releases/tag/2.0.2

@goncy
Copy link
Contributor Author

goncy commented Jul 16, 2019

@ntucker no, my bad, not an example but a demo. I think this one https://codesandbox.io/s/rest-hooks-hinux?fontsize=14&module=%2Fsrc%2Fpages%2FIssueList.tsx is really complex as a first impression of the library. Me as a new user landed on https://resthooks.io/ clicked demo before reading anything and saw a lot of files and that shocked me a little bit. Probably seeing a minimal example first is better for newcommers.

@ntucker
Copy link
Collaborator

ntucker commented Jul 17, 2019

Gotcha. Ok, having a simpler demo example to not overwhelm people. I'll put that on my future work; makes sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants