diff --git a/src/components/myLocation/HeaderComponent.jsx b/src/components/myLocation/HeaderComponent.jsx index 5435beb..e7ee2a9 100644 --- a/src/components/myLocation/HeaderComponent.jsx +++ b/src/components/myLocation/HeaderComponent.jsx @@ -20,6 +20,8 @@ const HeaderComponent = () => { const query = new URLSearchParams(location.search).get('content'); const [content, setContent] = useState(query || ''); + const [ addr, setAddr ] = useState(''); + useEffect(() => { const query = new URLSearchParams(location.search).get('content'); setContent(query || ''); @@ -66,8 +68,23 @@ const HeaderComponent = () => { try { const response = await instance.get(url); const data = response.data; - if (typeof data === 'number') { - setTotalCount(data); + if (data && typeof data === 'object') { + setTotalCount(data.totalCount); + console.log(data.totalCount); + + if (Array.isArray(data.address) && data.address.length > 0) { + const address = data.address[0]; + console.log(address.addr1); + console.log(address.addr2); + + if (address.addr1.endsWith('구')) { + setAddr(address.addr1); + } else { + setAddr(address.addr2); + } + } else { + console.error('addr 없다아악'); + } } else { console.error('Expected an array but got:', data); } @@ -85,16 +102,10 @@ const HeaderComponent = () => {