[0d34a1]: / client / src / API.js

Download this file

53 lines (42 with data), 973 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import axios from "axios"
const url = process.env.REACT_APP_API_URL
async function getTestCase(num) {
const route = 'test/' + num;
let response;
await axios.get(url + route)
.then(res => res.data)
.then((res) => {
response = res;
})
.catch((error) => {
console.log(error);
})
return response;
}
async function getTestResult(num) {
const route = 'testresult/' + num;
let response;
await axios.get(url + route)
.then(res => res.data)
.then((res) => {
response = res;
})
.catch((error) => {
console.log(error);
})
return response;
}
async function predict(json) {
const route = 'predict'
let response;
await axios.post(url + route, json)
.then(res => res.data)
.then((res) => {
response = res;
})
.catch((error) => {
console.log(error);
})
return response;
}
export { predict, getTestCase, getTestResult }