diff --git a/src/helper/util.js b/src/helper/util.js index 1aad995..a2dadda 100644 --- a/src/helper/util.js +++ b/src/helper/util.js @@ -16,10 +16,8 @@ const memoize = fun => { let cache = []; return input => { if (cache[input] !== undefined) return cache[input]; - fun(input).then(res => { - cache[input] = res; - return cache[input]; - }); + cache[input] = fun(input); + return cache[input]; }; }; diff --git a/src/index.js b/src/index.js index ded4364..42b0d20 100644 --- a/src/index.js +++ b/src/index.js @@ -5,10 +5,10 @@ const outputField = document.querySelector('input[name=response]'); const inputString = document.querySelector('input[name=request]'); const updateInputField = () => { - let res = postRequest(inputString.value); - - outputField.value = res; - inputString.value = ''; + postRequest(inputString.value).then(res => { + outputField.value = res.body; + inputString.value = ''; + }); }; const changeDisplayMsg = () => {