diff options
Diffstat (limited to 'src/api/logs.js')
| -rw-r--r-- | src/api/logs.js | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/api/logs.js b/src/api/logs.js index 59d064a..948a23f 100644 --- a/src/api/logs.js +++ b/src/api/logs.js @@ -1,5 +1,5 @@ import { - getAPIConfig, + getURLAndInit, genCommonHeaders, getAPIBaseURL } from 'm/request-helper'; @@ -10,16 +10,6 @@ const getRandomStr = () => { return Math.floor((1 + Math.random()) * 0x10000).toString(16); }; -function getURLAndInit() { - const c = getAPIConfig(); - const baseURL = getAPIBaseURL(c); - const headers = genCommonHeaders(c); - return { - url: baseURL + endpoint, - init: { headers } - }; -} - const Size = 300; let even = false; @@ -71,11 +61,11 @@ function pump(reader) { }); } -function fetchLogs() { +function fetchLogs(apiConfig) { if (store.fetched) return store; store.fetched = true; - const { url, init } = getURLAndInit(); - fetch(url, init) + const { url, init } = getURLAndInit(apiConfig); + fetch(url + endpoint, init) .then(response => { const reader = response.body.getReader(); pump(reader); |
