Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2017110273
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
sdy
2021-06-06 17:43:33 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
19e1b4132dfc5ebd88452fde8caed75a9966cd8d
19e1b413
1 parent
2fcc165b
add request functions
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
routes/api/server_watson.js
routes/api/server_watson.js
View file @
19e1b41
...
...
@@ -3,6 +3,11 @@ const router = express.Router();
const
AssistantV2
=
require
(
"ibm-watson/assistant/v2"
);
const
{
IamAuthenticator
}
=
require
(
"ibm-watson/auth"
);
const
request
=
require
(
'request'
);
const
parser
=
require
(
'xml2json'
);
const
coronaUrl
=
"http://openapi.data.go.kr/openapi/service/rest/Covid19/getCovid19InfStateJson"
;
const
queryParams
=
'?'
+
encodeURIComponent
(
'ServiceKey'
)
+
'=AZrC9RiqrxwllsI6PMbA9orNqoHCHvmriEKYHfdcpewFnbChIrmKpdehGjBt6fVGDbIAcwS0UVd7Ms5AMX29ig%3D%3D'
;
const
authenticator
=
new
IamAuthenticator
({
apikey
:
process
.
env
.
WATSON_ASSISTANT_APIKEY
,
});
...
...
@@ -44,4 +49,17 @@ router.post("/message", async (req, res) => {
}
});
router
.
get
(
"/corona"
,
async
(
req
,
res
)
=>
{
await
request
({
url
:
coronaUrl
+
queryParams
,
method
:
'GET'
},
(
err
,
r
,
body
)
=>
{
// console.log("err : ", err);
// console.log("res : ", res);
// console.log("body : ", body);
const
json
=
parser
.
toJson
(
body
);
res
.
send
(
json
);
});
});
module
.
exports
=
router
;
...
...
Please
register
or
login
to post a comment