Giter Site home page Giter Site logo

fetchcolorslist-api's Introduction

JS-07 - Fetch & Web Storage APIs



Example data

{
   "page": 1,
   "per_page": 6,
   "total": 12,
   "total_pages": 2,
   "data": [...],
}    

Part 1: Using the Axios

  1. Try sending GET request to https://reqres.in/api/data and observe the response.
  2. Each request will contain only 6 items. You will have to request multiple times to get all items.
  3. Add axios script to index.html
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    
  4. Update fetchColorsList to use axios to get data from https://reqres.in/api/data. Remember, You should check the "total_pages" in the first request then make more request to get more items from other pages then put all in "allColors" variable.
  5. If everything are correct, when go to index.html in browser. It should show all color in it.

Part 2: Using the Web Storage API

  1. Modify the fetchColorsList function so when the data is downloaded from the API, the colors list is stored using the local storage.
  2. Implement the loadColorsFromStorage function so the color values are loaded from the local storage.
  3. Open the developer tools and verify that the data is stored in the local storage.
  4. Test your application without connection to the internet and verify that the colors list is loaded.

Challenge Yourself

  1. Add a clear button that removes all the elements from the list.
  2. Add a load button that calls the fetchColorsList function and loads the colors again.

fetchcolorslist-api's People

Contributors

firstnapat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.