Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김시환
/
emergency_room_ChatBot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
root
2022-11-29 10:01:20 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
17bacaf117065f61c2fa01736f5545c1c6a793e4
17bacaf1
1 parent
27f9e8c7
update sample.js
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
6 deletions
sample.js
sample.js
View file @
17bacaf
...
...
@@ -28,23 +28,35 @@ var options = {
const
ID
=
'12rhzhzq7g'
;
const
KEY
=
'FhD45P91TxG2820MadrsiPOUjI6bQMJhddnHZIeI'
;
function
direction
(
data
){
async
function
direction
(
data
){
var
num
=
data
.
number
;
for
(
let
i
=
0
;
i
<
num
;
i
++
){
var
a
=
[]
for
(
let
i
=
0
;
i
<
num
;
i
++
){
a
.
push
(
'https://naveropenapi.apigw.ntruss.com/map-direction-15/v1/driving?start='
+
data
.
current_address
.
x
+
','
+
data
.
current_address
.
y
+
'&goal='
+
data
.
hospital_data
[
i
].
x
+
','
+
data
.
hospital_data
[
i
].
y
+
'&option=trafast'
)
}
console
.
log
(
a
)
const
PromiseList
=
a
.
map
(
async
(
e
)
=>
{
const
_url
=
'https://naveropenapi.apigw.ntruss.com/map-direction-15/v1/driving?start='
+
data
.
current_address
.
x
+
','
+
data
.
current_address
.
y
+
'&goal='
+
data
.
hospital_data
[
i
].
x
+
','
+
data
.
hospital_data
[
i
].
y
+
'&option=trafast'
;
options
.
url
=
_url
;
request
(
options
,
function
(
error
,
respose
){
return
await
request
(
options
,
function
(
error
,
respose
){
console
.
log
(
"11111111111111111"
)
var
databody
=
JSON
.
parse
(
respose
.
body
);
if
(
databody
.
code
!=
1
){
console
.
log
(
"2222222222222222"
)
console
.
log
(
databody
)
var
distance
=
databody
.
route
.
trafast
[
0
].
summary
.
distance
/
1000
;
// km 단위
var
duration
=
databody
.
route
.
trafast
[
0
].
summary
.
duration
/
1000
/
60
;
// 분 단위dy
data
.
hospital_data
[
i
].
distance
=
distance
;
console
.
log
(
data
.
hospital_data
[
i
].
distance
)
data
.
hospital_data
[
i
].
duration
=
duration
;}
})
}
})
const
result
=
await
Promise
.
all
(
PromiseList
)
console
.
log
(
"TTTTTTTTTTTTT"
)
return
data
}
console
.
log
(
result
)
return
result
}
console
.
log
(
direction
(
address
))
\ No newline at end of file
...
...
Please
register
or
login
to post a comment