Skip to content

Latest commit

 

History

History
29 lines (25 loc) · 630 Bytes

Readme.md

File metadata and controls

29 lines (25 loc) · 630 Bytes

React-Router-V6 & useNavigate & BrowserRouter & Axios

Installing

npm install

add the following import statement:

import { BrowserRouter,Route,Routes } from 'react-router-dom';

<Route path="/" element={<Users />} />
<Route path="/detail/:id" exact element={<UserDetail />} />

implemented the module of geting *json data from url using axios

  const fetchData = async () => {
    let response = await axios.get(
      "https://jsonplaceholder.typicode.com/posts/1/comments"
    );
    if (response.status === 200) {
      setUsers(response.data);
    }
  };