-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLookUpSymptoms.js
41 lines (36 loc) · 1.01 KB
/
LookUpSymptoms.js
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
const axios = require("axios");
const rp = require("request-promise");
function main(params) {
const symptom = params.symptoms;
const options = {
method: "POST",
uri: "",
json: true,
body: { name: symptom }
};
return rp(options)
.then(res => {
var data = "";
if (Object.keys(res).length > 1) {
data += "\n Did you mean any of the following : \n";
}
if (Object.keys(res).length == 1) {
isSymptom = true;
for (var key in res) {
data += res[key];
}
} else {
isSymptom = false;
for (var key in res) {
data += " \n ";
data += res[key];
}
}
var response = {
data: data,
isSymptom: isSymptom
};
return response;
})
.catch(err => console.log(err));
}