Fixing not working database/new admin endpoint
This commit is contained in:
parent
65d1710902
commit
6036556a37
@ -45,4 +45,4 @@
|
|||||||
"shortid": "^2.2.15",
|
"shortid": "^2.2.15",
|
||||||
"ws": "^7.1.2"
|
"ws": "^7.1.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,11 @@ import V1 from "./v1";
|
|||||||
|
|
||||||
const Web = new koa();
|
const Web = new koa();
|
||||||
|
|
||||||
Web.use(RequestLog)
|
Web.use(RequestLog);
|
||||||
Web.use(RequestError);
|
Web.use(RequestError);
|
||||||
Web.use(BodyParser({}))
|
Web.use(BodyParser({}));
|
||||||
|
|
||||||
Web.use(V1.routes())
|
Web.use(V1.routes());
|
||||||
Web.use(V1.allowedMethods())
|
Web.use(V1.allowedMethods());
|
||||||
|
|
||||||
export default Web;
|
export default Web;
|
@ -29,24 +29,24 @@
|
|||||||
<div id="message"> </div>
|
<div id="message"> </div>
|
||||||
<form id="f1" action="JavaScript:void(null)">
|
<form id="f1" action="JavaScript:void(null)">
|
||||||
{{#each fields}}
|
{{#each fields}}
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<label>{{label}}</label>
|
<label>{{label}}</label>
|
||||||
{{#ifCond type "===" "text"}}
|
{{#ifCond type "===" "text"}}
|
||||||
<input type="text" placeholder="{{label}}" name="{{name}}" value="{{value}}" />
|
<input type="text" placeholder="{{label}}" name="{{name}}" value="{{value}}" />
|
||||||
{{/ifCond}}
|
{{/ifCond}}
|
||||||
|
|
||||||
{{#ifCond type "===" "number"}}
|
{{#ifCond type "===" "number"}}
|
||||||
<input type="number" placeholder="{{label}}" name="{{name}}" value="{{value}}" />
|
<input type="number" placeholder="{{label}}" name="{{name}}" value="{{value}}" />
|
||||||
{{/ifCond}}
|
{{/ifCond}}
|
||||||
|
|
||||||
{{#ifCond type "===" "boolean"}}
|
{{#ifCond type "===" "boolean"}}
|
||||||
<input type="checkbox" name="{{name}}" checked="{{value}}" />
|
<input type="checkbox" name="{{name}}" checked="{{value}}" />
|
||||||
{{/ifCond}}
|
{{/ifCond}}
|
||||||
|
|
||||||
{{#ifCond type "===" "textarea"}}
|
{{#ifCond type "===" "textarea"}}
|
||||||
<textarea class="inp" name="{{name}}" rows="20">{{value}}</textarea>
|
<textarea class="inp" name="{{name}}" rows="20">{{value}}</textarea>
|
||||||
{{/ifCond}}
|
{{/ifCond}}
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
|
||||||
<button class="btn btn-primary" onclick="submitData()">Submit</button>
|
<button class="btn btn-primary" onclick="submitData()">Submit</button>
|
||||||
@ -55,14 +55,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const url = "{{url}}";
|
let u = new URL("{{url}}", window.location.origin);
|
||||||
|
let key = new URL(window.location.href).searchParams.get("key");
|
||||||
|
if (key)
|
||||||
|
u.searchParams.set("key", key);
|
||||||
|
|
||||||
const message = document.getElementById("message");
|
const message = document.getElementById("message");
|
||||||
const form = document.getElementById("f1");
|
const form = document.getElementById("f1");
|
||||||
function submitData() {
|
function submitData() {
|
||||||
let res = {};
|
let res = {};
|
||||||
Array.from(new FormData(form).entries()).forEach(([name, value]) => res[name] = value);
|
Array.from(new FormData(form).entries()).forEach(([name, value]) => res[name] = value);
|
||||||
fetch(url, {
|
fetch(u.href, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json"
|
"content-type": "application/json"
|
||||||
|
Reference in New Issue
Block a user