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

Hook API endpoints into the DataStore (front-end) #6

Open
louwie17 opened this issue Dec 15, 2021 · 0 comments
Open

Hook API endpoints into the DataStore (front-end) #6

louwie17 opened this issue Dec 15, 2021 · 0 comments

Comments

@louwie17
Copy link
Owner

We should make use of the new REST endpoints created on our server so we can persist the data on refresh.
We can replace the use of the localStorage use in the datastore with using the REST endpoint instead.

Gutenberg has a handy npm package for this called api-fetch, more documentation on how to install and use is here.

As part of this you could create a simple component that fetches all the products on load and displays either the number of created items, or a list with the title of each product.

Make use of the Promise structure first .then(...
After doing this method try out the async/await way

Acceptance criteria

  • Saving a new product should use the new REST api created in Create product rest endpoints #5
  • User should be able to refresh the page and notice how many products have been already created.
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