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 03980182d2
commit f6f2dfb8e4
No known key found for this signature in database
GPG Key ID: E8F9CD141E63BF38
2 changed files with 9 additions and 15 deletions

View File

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

View File

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