diff options
| author | Haishan <[email protected]> | 2018-12-04 23:39:26 +0800 |
|---|---|---|
| committer | Haishan <[email protected]> | 2018-12-07 00:19:49 +0800 |
| commit | 3584ff617966af35ddd0fd45ef2df7cdfb8f5071 (patch) | |
| tree | 83f4f535d1fd3ca1c85807a1c2b397cf9b6733c5 /src/api/traffic.js | |
| parent | a265c62020d4dd3a4e57e5ad0894794461dd8385 (diff) | |
feat: initial theming support
Diffstat (limited to 'src/api/traffic.js')
| -rw-r--r-- | src/api/traffic.js | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/api/traffic.js b/src/api/traffic.js index 12c88dc..8d1e3b7 100644 --- a/src/api/traffic.js +++ b/src/api/traffic.js @@ -1,21 +1,11 @@ import { - getAPIConfig, + getURLAndInit, genCommonHeaders, getAPIBaseURL } from 'm/request-helper'; const endpoint = '/traffic'; const textDecoder = new TextDecoder('utf-8', { stream: true }); -function getURLAndInit() { - const c = getAPIConfig(); - const baseURL = getAPIBaseURL(c); - const headers = genCommonHeaders(c); - return { - url: baseURL + endpoint, - init: { headers } - }; -} - const Size = 150; const traffic = { @@ -69,10 +59,10 @@ function pump(reader) { }); } -function fetchData() { +function fetchData(apiConfig) { if (fetched) return traffic; - const { url, init } = getURLAndInit(); - fetch(url, init).then(response => { + const { url, init } = getURLAndInit(apiConfig); + fetch(url + endpoint, init).then(response => { if (response.ok) { fetched = true; const reader = response.body.getReader(); |
