User DB snippet. (should work but other routing errors)

PHOTO EMBED

Tue Apr 13 2021 21:21:44 GMT+0000 (UTC)

Saved by @stephanieraymos

import React, { useState, useEffect } from "react";

const url = "http://143.110.225.28/account/user/"; //* API LINK

const UserDb = () => {
  //* Setting state values, params are default values
  const [users, setUsers] = useState([]);
  const [accessToken, setAccessToken] = useState("");
  const [refreshToken, setRefreshToken] = useState("");

  // //* Fetching the trucks db from the API link above
  // const fetchUsers = () => {
  //   const response = fetch(url, {
  //     method: "GET",
  //     headers: {
  //       "Content-Type": "application/json",
  //       Authorization: "Bearer " + accessToken,
  //     },
  //   });
  //   const newUsers = response
  //     .json() //returns a promise
  //     .then(setUsers(newUsers)) //Making sure the trucks list is current using newTrucks which adds each new truck to the truckLoad
  //     .then(setAccessToken("access_token"))
  //     .then(setRefreshToken("refresh_token"))
  //     .catch((error) => {
  //       console.log(error);
  //     });
  // };

  // useEffect(() => {
  //   fetchUsers();
  // }, []);

  return (
    <>
      {/* <div className="table-wrapper">
        <div className="header-items">
          <p className="all-trucks-table-header-name truck">FIRST NAME</p>
          <p className="all-trucks-table-header-price price">LAST NAME</p>
          <p className="all-trucks-table-header-contents contents">EMAIL</p>
        </div>

        <div className="truckLoad-list">
          {users.map((user) => {
            const { userId, firstName, lastName, email } = user;

            return (
              <div className="truckLoad" key={userId}>
                <p className="items all-trucks-name">{firstName}</p>
                <p className="items all-trucks-price">{lastName}</p>
                <p className="items all-trucks-contents">{email}</p>
              </div>
            );
          })}
        </div>
      </div> */}
    </>
  );
};
export default UserDb;
content_copyCOPY