Merge pull request #176 from colin-campbell/headers-api-everywhere

Add headers to every API call
This commit is contained in:
Muhammed Nazeem
2024-08-22 22:37:14 +05:30
committed by GitHub
7 changed files with 33 additions and 13 deletions

View File

@@ -1,5 +1,5 @@
import { setBadgeBackgroundColor, setBadgeText, setTitle } from "@/utils/action"
import fetcher from "@/libs/fetcher"
export const progressHuman = (completed: number, total: number) => {
return ((completed / total) * 100).toFixed(0) + "%"
@@ -11,7 +11,7 @@ export const clearBadge = () => {
}
export const streamDownload = async (url: string, model: string) => {
url += "/api/pull"
const response = await fetch(url, {
const response = await fetcher(url, {
method: "POST",
headers: {
"Content-Type": "application/json"

View File

@@ -1,7 +1,8 @@
import { cleanUrl } from "~/libs/clean-url"
import fetcher from "@/libs/fetcher"
export const verifyPageShareURL = async (url: string) => {
const res = await fetch(`${cleanUrl(url)}/api/v1/ping`)
const res = await fetcher(`${cleanUrl(url)}/api/v1/ping`)
if (!res.ok) {
throw new Error("Unable to verify page share")
}