-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.js
27 lines (23 loc) · 819 Bytes
/
api.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
const superagent = require("superagent");
const config = require("./config");
async function getQuestionPaper(id) {
const response = (await superagent.get(`http://pingjiao.sjtu.edu.cn/api/question-paper/8/15/${id}`)
.set(config.request));
return response.body.questions;
}
async function getCourseList() {
const response = (await superagent.get("http://pingjiao.sjtu.edu.cn/api/my-message/15")
.set(config.request));
return response.body.course_list;
}
async function sendAnswer(id, answers) {
const response = (await superagent.post(`http://pingjiao.sjtu.edu.cn/api/evaluation-paper/8/15/${id}`)
.send(JSON.stringify(answers))
.set(config.request));
return response.body.message;
}
module.exports = {
getQuestionPaper,
getCourseList,
sendAnswer
}