I checked this backend code using Postman. It sometimes works properly. But, sometimes, it does not work. What's the matter with this code?
I used the technology koa.js. I create dao file, api file, and router file to handle the backend.
studentRouter.put("/:id", async ctx=>{
var ObjectID = require('mongodb').ObjectId;
var id = new ObjectID(ctx.params.id);
let student = ctx.request.body;
student = updateStudent(id,student);
ctx.set('Context-Type','application/json' );
ctx.body = {success:true, existingData:student}
ctx.status = 200;
})