윤규리

move selectAddress

1 import fetch from "node-fetch"; 1 import fetch from "node-fetch";
2 globalThis.fetch = fetch; 2 globalThis.fetch = fetch;
3 3
4 -var currAddress = new Array(); 4 +var AddressList = new Array();
5 -function getAdddress(currQuery) { 5 +
6 +
7 +function getAddress(currQuery) {
6 fetch('https://dapi.kakao.com/v2/local/search/address.json?' + new URLSearchParams({ 8 fetch('https://dapi.kakao.com/v2/local/search/address.json?' + new URLSearchParams({
7 query: currQuery 9 query: currQuery
8 }), { 10 }), {
...@@ -11,17 +13,42 @@ function getAdddress(currQuery) { ...@@ -11,17 +13,42 @@ function getAdddress(currQuery) {
11 }) 13 })
12 .then(response => response.json()) 14 .then(response => response.json())
13 .then(data => { 15 .then(data => {
14 - currAddress = data.documents.map(({road_address})=>({road_address})); 16 + AddressList = data.documents.map(({road_address})=>({road_address}));
15 // console.log(currAddress) 17 // console.log(currAddress)
16 - return currAddress 18 + return AddressList
17 }) 19 })
18 } 20 }
19 21
20 -function selectAddress(addressArray, number) {
21 22
23 +
24 +
25 +/*
26 +
27 + move to Line
28 +
29 +var x; var y;
30 +var regions = new Array();
31 +
32 +
33 +// addressArray <- return value from function getAddress
34 +
35 +function selectAddress(addressArray, number) {
36 + x = addressArray[number].road_address.x
37 + y = addressArray[number].road_address.y
38 + regions.region_1depth_name = addressArray[number].road_address.region_1depth_name;
39 + regions.region_2depth_name = addressArray[number].road_address.region_2depth_name;
40 + regions.region_3depth_name = addressArray[number].road_address.region_3depth_name;
41 +
22 } 42 }
23 43
24 -function getXY() { 44 +*/
45 +
46 +
47 +// hospitals: array from hospital API
48 +// addNum: index of addressArray
49 +function getXY(hospitals, addNum) {
50 +
51 + AddressList = null;
25 52
26 } 53 }
27 -module.exports = {getAddress, selectAddress, getXY};
...\ No newline at end of file ...\ No newline at end of file
54 +module.exports = {getAddress, getXY};
...\ No newline at end of file ...\ No newline at end of file
......