Diff of /client/src/API.js [000000] .. [0d34a1]

Switch to unified view

a b/client/src/API.js
1
import axios from "axios"
2
3
const url = process.env.REACT_APP_API_URL
4
5
async function getTestCase(num) {
6
    const route = 'test/' + num;
7
    let response;
8
9
    await axios.get(url + route)
10
    .then(res => res.data)
11
    .then((res) => {
12
        response = res;
13
    })
14
    .catch((error) => {
15
        console.log(error);
16
    })
17
18
    return response;
19
}
20
21
async function getTestResult(num) {
22
    const route = 'testresult/' + num;
23
    let response;
24
25
    await axios.get(url + route)
26
    .then(res => res.data)
27
    .then((res) => {
28
        response = res;
29
    })
30
    .catch((error) => {
31
        console.log(error);
32
    })
33
34
    return response;
35
}
36
37
async function predict(json) {
38
    const route = 'predict'
39
    let response;
40
    
41
    await axios.post(url + route, json)
42
    .then(res => res.data)
43
    .then((res) => {
44
        response = res;
45
    })
46
    .catch((error) => {
47
        console.log(error);
48
    })
49
50
    return response;
51
}
52
53
export { predict, getTestCase, getTestResult }