Git Product home page Git Product logo

cats-galore's Introduction

Cats Galore

Table of contents

  • Fork this repo. Copy the new repo URL and run git clone in your terminal. cd into the new directory and run these commands.
npm install
json-server --watch db.json
  • Open up a new terminal and run the following command:
npm start
  • The terminal will ask you to start a new server since we already have the JSON server running on localhost:3000. Enter y to start a new server on localhost:3001.
  • Open http://localhost:3001 in the browser to see your app.
  • Make a copy of db.json and save it as original_db.json. This is so that you can always refer back to the original database in case you mess up the database with incorrect PATCH requests.

READ: See all the cats on the page

  • Make a GET fetch request to http://localhost:3000/cats

CREATE: a new cat through the form

  • Make a POST fetch request to http://localhost:3000/cats

UPDATE: Increase a cat's likes

  • Make a PATCH fetch request to http://localhost:3000/cats/id
  • Display all the cats in the CatsContainer as a CatTile component.
  • Each CatTile should display the cat's picture, name, number of likes, a "like" button, and a "learn more" button.
  • Clicking on the "learn more" button for a cat will display more of the cat's information below the button. The information should be something like this: "Kenny's favorite toy is a baby dog and they are a 8-year old female cat." Clicking on the "learn more" button again will hide this information.
  • Add a new cat by filling out the form.
  • On the home page, dynamically search for a cat by its name.
  1. If you see a key in a JSON object that has whitespaces, reassign the key to something more workable For example:
{
  "id": 1,
  "likes": 22,
  "this is a string": "hello, world!",
}

// reassign the key
["this is a string"]: string

// or use bracket notation without reassigning it
this.state["this is a string"]
  1. Before you tackle the search functionality, think about what information you need to send up and down as props. Where are you going to save the user's input from the search bar? And what kind of logic do you need to write to filter all the cats?

  2. For displaying the cat's information, use string interpolation to combine the cat's different attributes. For example:

<p>{name}'s favorite toy is a {toy} and they are a {age}-year old {sex} cat.</p>
  1. What kind of event listener do you need to add to a cat's "learn more" button to toggle their information? And where can you save the state for this toggle?

screenshot of home page

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.