-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
15 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
export const downloadJsonFromIpfs = async <T>(uri: string): Promise<T> => { | ||
let url = uri; | ||
if (!url.startsWith("http")) { | ||
const baseUrl = Deno.env.get("IPFS_URL"); | ||
if (!baseUrl) { | ||
throw new Error("IPFS_URL is not set"); | ||
} | ||
import { getEnv } from "../utils/env.ts"; | ||
|
||
url = `${baseUrl}/${url}`; | ||
export const downloadJsonFromIpfs = async <T>(uri: string): Promise<T> => { | ||
let url = uri; | ||
if (!url.startsWith("http")) { | ||
const baseUrl = getEnv("IPFS_URL"); | ||
if (!baseUrl) { | ||
throw new Error("IPFS_URL is not set"); | ||
} | ||
|
||
const response = await fetch(url); | ||
const json = await response.json(); | ||
url = `${baseUrl}/${url}`; | ||
} | ||
|
||
const response = await fetch(url); | ||
const json = await response.json(); | ||
|
||
return json; | ||
return json; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters