diff --git a/src/App.jsx b/src/App.jsx
index 6478b09..b037a13 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,25 +1,61 @@
import { useState } from "react";
import "./App.css";
-function City(props) {
- return
This is the City component
;
+function City(city) {
+ return (
+
+
+
{city.city.LocationText}
+
+
+ - State: {city.city.State}
+ - Location: ({city.city.Lat}, {city.city.Long})
+ - Population (estimated): {city.city.EstimatedPopulation}
+ - Total Wages: {city.city.TotalWages}
+
+
+
+
+ )
}
-function ZipSearchField(props) {
- return This is the ZipSearchField component
;
+function ZipSearchField({ setCityData }) {
+ const fetchZipcodes = (zipcode) => {
+ fetch(`https://ctp-zip-code-api.onrender.com/zip/${zipcode}`)
+ .then((response) => response.json())
+ .then((data) => setCityData(data))
+ .catch(() => setCityData(null))
+ }
+ const onChange = () => {
+ const zip = document.getElementById('zipcode')
+ fetchZipcodes(zip.value)
+ }
+ return (
+
+ )
}
function App() {
+ const [ cityData, setCityData ] = useState()
+ console.log(cityData)
return (
Zip Code Search
-
-
-
-
+
+
+ { cityData && cityData.length > 0 ? cityData.map((city) => {
+ return (
+
+ )
+ }) : <>>}