Preview:
//Fetching the trucks db from the API link above //^----POST (ADD INVENTORY)----
  const postTrucks = async () => {
    try {
      const response = await fetch("http://143.110.225.28/api/v1/inventory/", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({
          truckName: truckName,
          truckPrice: truckPrice,
          truckContents: truckContents,
          truckManifest: truckManifest,
        }),
      });
      const data = response.json();
      const { trucks } = data;

      if (trucks) {
        const newTrucks = trucks.map((truck) => {
          const { truckName, truckPrice, truckContents, truckManifest } = truck;
        });
        setTrucks(newTrucks);
      } else {
        setTrucks([]);
      }
    } catch (error) {
      console.log(error);
    }
  };
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter