From 980f06ed73012f8608ee7fc221187e55ddc07d24 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Thu, 15 Jul 2021 10:05:25 +0300 Subject: [PATCH] Island UI: fix a bug in IslandHttpClient.tsx that caused the body of a Response object to be a promise instead of an object --- .../cc/ui/src/components/IslandHttpClient.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/IslandHttpClient.tsx b/monkey/monkey_island/cc/ui/src/components/IslandHttpClient.tsx index 842fa6333..1c9571011 100644 --- a/monkey/monkey_island/cc/ui/src/components/IslandHttpClient.tsx +++ b/monkey/monkey_island/cc/ui/src/components/IslandHttpClient.tsx @@ -13,18 +13,22 @@ export class Response{ class IslandHttpClient extends AuthComponent { post(endpoint: string, contents: any): Promise{ + let status = null; return this.authFetch(endpoint, { method: 'POST', headers: {'Content-Type': 'application/json'}, body: JSON.stringify(contents) }) - .then(res => new Response(res.json(), res.status)); + .then(res => {status = res.status; return res.json()}) + .then(res => new Response(res, status)); } get(endpoint: string): Promise{ + let status = null; return this.authFetch(endpoint) - .then(res => new Response(res.json(), res.status)); + .then(res => {status = res.status; return res.json()}) + .then(res => new Response(res, status)); } }