https post

This commit is contained in:
barwie2@st.amu.edu.pl 2020-03-09 22:54:42 +01:00
parent 06fd87b9c9
commit 414cceacb2
1 changed files with 8 additions and 5 deletions

View File

@ -22,10 +22,10 @@ var server = http.createServer(function (request, response) {
request.on('data', function (chunk) {
body += chunk;
});
try {
request.on('end', function () {
body = JSON.parse(body);
request.on('end', function () {
try {
body = JSON.parse(body);
var send_array = {
"type": "data",
"id": body.student_index,
@ -35,8 +35,11 @@ var server = http.createServer(function (request, response) {
};
lookup[body.classes_code].send(JSON.stringify(send_array));
response.end("Added");
});
} catch (e) {console.log(e)}
} catch (e) {
console.log(e);
}
});
}
else {
response.end("Undefined request .");