root

Merge branch 'main' into sihwan

Showing 1 changed file with 22 additions and 14 deletions
...@@ -6,22 +6,30 @@ globalThis.fetch = fetch.fetch; ...@@ -6,22 +6,30 @@ globalThis.fetch = fetch.fetch;
6 var AddressList = new Array(); 6 var AddressList = new Array();
7 7
8 8
9 -function getAddress(currQuery) { 9 +function getAddress(currQuery, cb = ()=> {}) {
10 - fetch('https://dapi.kakao.com/v2/local/search/address.json?' + new URLSearchParams({ 10 + setTimeout(function () {
11 - query: currQuery 11 + fetch('https://dapi.kakao.com/v2/local/search/address.json?' + new URLSearchParams({
12 - }), { 12 + query: currQuery
13 - method: "GET", 13 + }), {
14 - headers: {"Authorization": "KakaoAK c14234ba46c574c73715276c5644f397"} 14 + method: "GET",
15 - }) 15 + headers: { "Authorization": "KakaoAK c14234ba46c574c73715276c5644f397" }
16 - .then(response => response.json()) 16 + })
17 - .then(data => { 17 + .then(response => response.json())
18 - console.log(response) 18 + .then(data => {
19 - AddressList = data.documents.map(({road_address})=>({road_address})); 19 + //console.log(response)
20 - console.log(AddressList) 20 + AddressList = data.documents.map(({ road_address }) => ({ road_address }));
21 - return AddressList 21 + //console.log(AddressList)
22 - }) 22 + cb(AddressList);
23 + });
24 +
25 + },100)
23 } 26 }
24 27
28 +/*
29 +getAddress('석수동길', function (address) {
30 + console.log(address[0].road_address.address_name);
31 +})
32 +*/
25 33
26 34
27 35
......