You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 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:
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.
The text was updated successfully, but these errors were encountered:
brandonaaskov
changed the title
Setup Example Using Rocket Employees
Setup Store Using Rocket Employees
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: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 thatitems
array.The text was updated successfully, but these errors were encountered: