diff --git a/package.json b/package.json index 464f34c1..a1131a38 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 20761999..d40cb594 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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 diff --git a/src/components/ui/UniMedia.tsx b/src/components/ui/UniMedia.tsx index 95fa8ace..041990e4 100644 --- a/src/components/ui/UniMedia.tsx +++ b/src/components/ui/UniMedia.tsx @@ -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) {} } diff --git a/src/lib/upload-file.ts b/src/lib/upload-file.ts index b7d51dd6..345a27a0 100644 --- a/src/lib/upload-file.ts +++ b/src/lib/upload-file.ts @@ -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, } } diff --git a/src/models/page.model.ts b/src/models/page.model.ts index db7bdc97..568efb23 100644 --- a/src/models/page.model.ts +++ b/src/models/page.model.ts @@ -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( 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 }