diff options
Diffstat (limited to 'animism-align/frontend/util/index.js')
| -rw-r--r-- | animism-align/frontend/util/index.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/animism-align/frontend/util/index.js b/animism-align/frontend/util/index.js index 194ecf0..baa121c 100644 --- a/animism-align/frontend/util/index.js +++ b/animism-align/frontend/util/index.js @@ -52,7 +52,7 @@ export const courtesyS = (n, s) => n + ' ' + (n === 1 ? s : s + 's') export const padSeconds = n => n < 10 ? '0' + n : n -export const timestamp = (n = 0, fps = 25) => { +export const timestamp = (n = 0, fps = 1) => { n /= fps let s = padSeconds(Math.round(n) % 60) n = Math.floor(n / 60) @@ -224,12 +224,17 @@ export const api = (dispatch, type=api_type, tag, url, data) => { if (data) { url.search = new URLSearchParams(data).toString() } - return fetch(url, { + let req = fetch(url, { method: 'GET', // mode: 'cors', }) - .then(res => res.json()) - .then(res => dispatch({ + // console.log(tag) + if (tag === 'text') { + req = req.then(res => res.text()) + } else { + req = req.then(res => res.json()) + } + req = req.then(res => dispatch({ type: type.loaded, tag, data: res, @@ -239,6 +244,7 @@ export const api = (dispatch, type=api_type, tag, url, data) => { tag, err, })) + return req } /* sorting */ |
