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

Setup Store Using Rocket Employees #16

Open
brandonaaskov opened this issue Jul 13, 2021 · 0 comments
Open

Setup Store Using Rocket Employees #16

brandonaaskov opened this issue Jul 13, 2021 · 0 comments

Comments

@brandonaaskov
Copy link
Contributor

brandonaaskov commented Jul 13, 2021

There's a contrived example in there right now around movies, just to use some of the various store methods and make sure they're testable. But it's boring. So let's use some Rocket-related stuff instead. This PR is just focused on the business store logic, nothing display related.

We use Contentful on our website and there's a public API we can use to fetch the team details.
https://cdn.contentful.com/spaces/eq7v79j9q2bj/entries?access_token=002313db02188f7993bf8e6f0c498c5dca85d796115c35908738242d9808cc92&content_type=team

We should store the spaces id and the access_token as environment variables instead of hardcoding them in the string.

Let's setup a Rocket store (rocket.js) for this stuff. For now, everything comes back in one page so we don't have to worry about paging the API call for now. Here's what we want to pull out of the response and keep in the store for later:
image

That profile pic ID will need to be built into a URL string so we can actually show the images on screen, but that's a great use-case for a getter that returns a function, a more advanced use case of getters.

This is also a great case for setting up a basic test. I like integration tests so we know if things are working as we expect, as opposed to mocking out services like that Contentful fetch there. Let's just have three tests for now: one that the request comes back with a 200 status code, another that shows that items array isn't empty, and another that shows that those fields we're pulling exist on the first item in that items array.

@brandonaaskov brandonaaskov changed the title Setup Example Using Rocket Employees Setup Store Using Rocket Employees Jul 13, 2021
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

1 participant