URL HTTP Verb Action Description
/subjects GET index Show all items
/subjects/new GET new Show new form
/subjects POST create Create an item
/subjects/:id GET show Show item with :id
/subjects/:id/edit GET edit Show edit form for item with :id
/subjects/:id PATCH update Update item with :id
/subjects/:id/delete GET delete Show delete form for item with :id
/subjects/:id DELETE destroy Delete item with :id

-GET: 데이터를 가져올 때(fetch 쓸 때 기본 명령어 속성이 GET)

-POST: 데이터를 생성할 때

-PUT: 데이터를 수정할 때(patch라고도 불림)

-DELETE: 데이터를 삭제할 때


📌Parameter

:id → url상의 파라미터이다.

동적으로 url을 보여줄 수 있다.

<Route path="/products/**:id**" element={<ProductDetail />} />
import React from "react";
import { useParams } from "react-router-dom";

export default function ProductDetail() {
  const params = useParams();
  **console.log("params", params);**
  return (
    <div>
      <h1>Products Detail!!</h1>
    </div>
  );
}

✏️path로 :id 값을 지정해 줬을 때

Untitled

Untitled

✏️path로 :id/:num 값을 지정해 줬을 때

<Route path="/products/**:id/:num**" element={<ProductDetail />} />

Untitled

Untitled