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