From e223e1ae752823f1546dd9cf5131d3d425aa635d Mon Sep 17 00:00:00 2001 From: Killer Boss Original <73131550+killerbossoriginal@users.noreply.github.com> Date: Fri, 8 Jul 2022 20:02:32 +0200 Subject: [PATCH] Update index.js --- index.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index af37f7d..1356119 100644 --- a/index.js +++ b/index.js @@ -103,7 +103,29 @@ async function searchElement(request, response) { // Set a db variable -app.put('/api/:auth/database/:element/set/:data', set); +app.put('/api/:auth/database/:element/set/:data', (request, response) => { + var token = request.params.auth; + var element = request.params.element; + var data = request.params.data; + + set = 'set '+element+' to '+data + authenticate(token, response, set) + + await db.set(element, data) + var res = await db.get(element) +// var res = JSON.parse(res); + if(res) { + var reply = { + status: 'Done' + }; + } else { + var reply = { + status:"404 - Not Found" + } + } + + response.send(reply); +}); async function set(request, response) { var token = request.params.auth;