diff --git a/src/App.jsx b/src/App.jsx index 6478b09..9b39288 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,15 +1,50 @@ import { useState } from "react"; import "./App.css"; +const url="https://ctp-zip-code-api.onrender.com/zip/" +let [cities, getCityData]= useState([]) + function City(props) { - return
This is the City component
; + return

{props.City}

+ +
; + } function ZipSearchField(props) { - return
This is the ZipSearchField component
; + return
This is the ZipSearchField component
+
; +} + +async function getCityData(){ + const zipcode= document.getElementById("zip").value; + if(!zipcode){ + return + } + if(zipcode.length!=5){ + return + } + console.log(zipcode) + try{ + const response= fetch(url+zipcode) + const data= (await response).json() + cities=data + console.log(cities) + + } + catch(error){ + console.log(error) + } + } function App() { + return (
@@ -17,6 +52,10 @@ function App() {
+ {cities.map((e) => { + return + })}