chore: remove axios (#469)

This commit is contained in:
enpitsulin 2023-05-01 08:53:56 +08:00 committed by GitHub
parent 6ea4fc7492
commit f486adc388
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 32 deletions

View File

@ -60,7 +60,6 @@
"@urql/core": "4.0.7",
"ahooks": "^3.7.6",
"aplayer-react": "^1.1.0",
"axios": "1.4.0",
"canvas-confetti": "^1.6.0",
"chroma-js": "^2.4.2",
"clsx": "1.2.1",

View File

@ -100,9 +100,6 @@ dependencies:
aplayer-react:
specifier: ^1.1.0
version: 1.1.0(react@18.2.0)
axios:
specifier: 1.4.0
version: 1.4.0
canvas-confetti:
specifier: ^1.6.0
version: 1.6.0
@ -162,7 +159,7 @@ dependencies:
version: 0.16.7
langchain:
specifier: ^0.0.66
version: 0.0.66(axios@1.4.0)
version: 0.0.66
lottie-react:
specifier: ^2.4.0
version: 2.4.0(react-dom@18.2.0)(react@18.2.0)
@ -9593,7 +9590,7 @@ packages:
engines: {node: '>=6'}
dev: false
/langchain@0.0.66(axios@1.4.0):
/langchain@0.0.66:
resolution: {integrity: sha512-HsVdXFDp2+YB12tvpMFOK6kIXaLvFzJKQUzitr5VEamhZCFUoojZgcS7ckRjxJIv+aVWbEzCi3KJI/2kPKsMkA==}
engines: {node: '>=18'}
peerDependencies:
@ -9688,7 +9685,6 @@ packages:
dependencies:
'@anthropic-ai/sdk': 0.4.3
'@dqbd/tiktoken': 1.0.7
axios: 1.4.0
binary-extensions: 2.2.0
browser-or-node: 2.1.1
expr-eval: 2.0.2

View File

@ -1,4 +1,3 @@
import axios from "axios"
import React, { useState } from "react"
import { Image } from "~/components/ui/Image"
@ -16,11 +15,13 @@ export const UniMedia: React.FC<{
const src = e.target.getAttribute("original-src")
if (src && !errorHandled) {
try {
const result = await axios({
url: src.replace(IPFS_GATEWAY, "https://gateway.ipfs.io/ipfs/"),
method: "HEAD",
})
setType(result.headers["content-type"])
const response = await fetch(
src.replace(IPFS_GATEWAY, "https://gateway.ipfs.io/ipfs/"),
{
method: "HEAD",
},
)
setType(response.headers.get("content-type") ?? "")
setErrorHandled(true)
} catch (error) {}
}

View File

@ -1,19 +1,12 @@
import axios from "axios"
export const UploadFile = async (blob: Blob) => {
const formData = new FormData()
formData.append("file", blob)
const res = await axios.post(
const response = await fetch(
"https://ipfs-relay.crossbell.io/upload?gnfd=t",
formData,
{
headers: {
"Content-Type": "multipart/form-data",
},
},
{ method: "POST", body: formData },
)
return {
key: res.data.url,
key: (await response.json()).url,
}
}

View File

@ -1,4 +1,3 @@
import axios from "axios"
import { NoteMetadata } from "crossbell.js"
import type { Contract } from "crossbell.js"
import type Unidata from "unidata.js"
@ -345,14 +344,14 @@ export async function getPage<TRender extends boolean = false>(
if (!mustLocal) {
// on-chain page
if (!input.pageId) {
const slug2Id = (
await axios.get("/api/slug2id", {
params: {
handle: input.site,
slug: input.page,
},
})
).data
if (!input.site || !input.page) return null
const response = await fetch(
`/api/slug2id?${new URLSearchParams({
handle: input.site,
slug: input.page,
}).toString()}`,
)
const slug2Id = await response.json()
if (!slug2Id?.noteId) {
return null
}