-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (28 loc) · 699 Bytes
/
index.js
File metadata and controls
30 lines (28 loc) · 699 Bytes
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
const axios = require("axios");
async function runCode(url, language, index, input, clientId, clientSecret) {
var output = "";
const body = await axios.get(url);
const data = await axios
.post(
"https://api.jdoodle.com/v1/execute",
{
script: body.data,
language: language,
stdin: input,
versionIndex: index,
clientId: clientId,
clientSecret: clientSecret,
},
{
headers: {
"Content-Type": "application/json; charset=UTF-8",
},
}
)
.then((response) => {
output = response.data["output"];
})
.catch((error) => {});
return output;
}
module.exports = { runCode };