Posts

Showing posts with the label koa2

How to stop the same data into database when the network is so slow

Image
Clash Royale CLAN TAG #URR8PPP How to stop the same data into database when the network is so slow I use following code to accept the regsiter call from client regsiter .post('/regsiter', async (ctx) => { requestfrom = JSON.parse(JSON.stringify(ctx.request.body)) let regxemail = /^[a-z0-9]+([._\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/; let email = requestfrom.email let password = md5(requestfrom.password) if (regxemail.test(email)) { await userModel.checkemailexist([email]) .then(async(result) => { if (result.length === 0) { console.log("insert email to database") await userModel.insertUser([email,password]) } else { console.log("email exist") } }) } }) If the visiter's network is well, this function will work well, but if the visiter's network is so slow, there's no enough response time, and it will...