aboutsummaryrefslogtreecommitdiff
path: root/frontend/src/http/useFetchPaste.js
diff options
context:
space:
mode:
authorjackyzha0 <[email protected]>2021-04-11 12:30:02 -0700
committerjackyzha0 <[email protected]>2021-04-11 12:30:02 -0700
commit12c995b6bd501be73b60e3bae6c46c59cebef6c2 (patch)
tree6e2deaff7d1fd4998fa2f688b15294979a510af3 /frontend/src/http/useFetchPaste.js
parentworking raw paste fetch (diff)
downloadctrl-v-12c995b6bd501be73b60e3bae6c46c59cebef6c2.tar.xz
ctrl-v-12c995b6bd501be73b60e3bae6c46c59cebef6c2.zip
base resolve paste and fetch paste refactor
Diffstat (limited to 'frontend/src/http/useFetchPaste.js')
-rw-r--r--frontend/src/http/useFetchPaste.js43
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