From 9343d2ea697f13e52e9199fce62a959f1954f580 Mon Sep 17 00:00:00 2001 From: Brian Picciano Date: Mon, 30 Aug 2021 20:08:51 -0600 Subject: add chat handlers and only allow POST methods --- static/src/assets/api.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'static/src/assets') diff --git a/static/src/assets/api.js b/static/src/assets/api.js index b591764..7ce2e89 100644 --- a/static/src/assets/api.js +++ b/static/src/assets/api.js @@ -31,7 +31,7 @@ const doFetch = async (req) => { // may throw const solvePow = async () => { - const res = await call('GET', '/api/pow/challenge'); + const res = await call('/api/pow/challenge'); const worker = new Worker('/assets/solvePow.js'); @@ -46,8 +46,12 @@ const solvePow = async () => { return {seed: res.seed, solution: powSol}; } -const call = async (method, route, opts = {}) => { - const { body = {}, requiresPow = false } = opts; +const call = async (route, opts = {}) => { + const { + method = 'POST', + body = {}, + requiresPow = false, + } = opts; if (!utils.cookies["csrf_token"]) throw "csrf_token cookie not set, can't make api call"; -- cgit v1.2.3