diff options
Diffstat (limited to 'frontend/src/http/useFetchPaste.js')
| -rw-r--r-- | frontend/src/http/useFetchPaste.js | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/frontend/src/http/useFetchPaste.js b/frontend/src/http/useFetchPaste.js deleted file mode 100644 index 8d40cbe..0000000 --- a/frontend/src/http/useFetchPaste.js +++ /dev/null @@ -1,43 +0,0 @@ -import {useEffect, useState} from 'react' -import {fetchPaste, fmtDateStr} from './shared' -import {LANGS} from "../components/renderers/Code"; - -const resolvePaste = (id, password = "") => { - const response = { - data: { - title: '', - content: '', - language: LANGS.detect, - expiry: '', - }, - unauthorized: false, - error: '', - } - return fetchPaste(id, password) - .then(resp => { - const data = resp.data - response.data = { - ...data, - expiry: fmtDateStr(data.expiry) - } - return response - }) - .catch(error => { - const resp = error.response - if (!resp) { - response.error = 'network error' - return - } - - if (resp.status === 401) { - response.error = 'unauthorized' - response.unauthorized = true - return - } - - response.error = `${resp.status}: ${resp.data}` - return response - }) -} - -export default resolvePaste
\ No newline at end of file |