diff --git a/src/components/Status.tsx b/src/components/Status.tsx index fd90f67..d550284 100644 --- a/src/components/Status.tsx +++ b/src/components/Status.tsx @@ -11,9 +11,9 @@ export default function Status({ type }: { type: string }): ReactElement { const url = type === 'gateway' ? `${ipfsGateway}/ipfs/QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG/readme` - : `${ipfsNodeUri}/api/v0/id` - - const ping = await pingUrl(url) + : `${ipfsNodeUri}/api/v0/version` + const method = type === 'gateway' ? 'get' : 'post' + const ping = await pingUrl(url, method) setIsLoading(false) setIsOnline(ping) }, [type]) diff --git a/src/utils.ts b/src/utils.ts index ea42f1a..3ccf8d1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -9,9 +9,12 @@ export function formatBytes(a: number, b: number): string { return parseFloat((a / Math.pow(c, f)).toFixed(d)) + ' ' + e[f] } -export async function pingUrl(url: string): Promise { +export async function pingUrl( + url: string, + method?: 'get' | 'post' +): Promise { try { - const response = await axios(url, { timeout: 5000 }) + const response = await axios[method || 'get'](url, { timeout: 5000 }) if (!response || response.status !== 200) return false return true } catch (error) {