dummy methods wired up to return values to the front-end

This commit is contained in:
kevmodrome 2020-07-02 18:38:00 +02:00
parent b6f3a1e32d
commit a5d33854da
2 changed files with 9 additions and 15 deletions

View File

@ -6,11 +6,10 @@
let keys = { budibase: "", sendGrid: "" } let keys = { budibase: "", sendGrid: "" }
async function updateKey(e) { async function updateKey([key, value]) {
console.log("Event Key: ", e.detail) const response = await api.put(`/api/keys/${key}`, { value })
// Send to endpoint when it exists const res = await response.json()
const response = await api.put(`/api/${$store.appId}`, data) keys = { ...keys, ...res }
// const res = await response.json()
} }
// Get Keys // Get Keys
@ -27,7 +26,7 @@
<div class="container"> <div class="container">
<div class="background"> <div class="background">
<Input <Input
on:save={updateKey} on:save={e => updateKey(['budibase', e.detail])}
thin thin
edit edit
value={keys.budibase} value={keys.budibase}
@ -35,7 +34,7 @@
</div> </div>
<div class="background"> <div class="background">
<Input <Input
on:save={updateKey} on:save={e => updateKey(['sendgrid', e.detail])}
thin thin
edit edit
value={keys.sendgrid} value={keys.sendgrid}

View File

@ -18,15 +18,10 @@ exports.fetch = async function (ctx) {
} }
exports.update = async function (ctx) { exports.update = async function (ctx) {
// Do something with ctx.request.body: <{ value: value }>
ctx.status = 200 ctx.status = 200
ctx.message = `Updated ${ctx.params.key} succesfully.` ctx.message = `Updated ${ctx.params.key} API key succesfully.`
ctx.body = { ctx.body = { [ctx.params.key]: ctx.request.body.value }
[ctx.params.key]: "somethingsomethingsomething"
}
ctx.status = 200
ctx.message = `User ${ctx.request.body.username} updated successfully.`
ctx.body = response
} }
const checkAccessLevel = async (db, accessLevelId) => { const checkAccessLevel = async (db, accessLevelId) => {