Initial commit with 🏗️ Scaffold-ETH 2 @ 1.0.5
This commit is contained in:
16
packages/nextjs/utils/tokenization/ipfs-fetch.ts
Normal file
16
packages/nextjs/utils/tokenization/ipfs-fetch.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
const fetchFromApi = ({ path, method, body }: { path: string; method: string; body?: object }) => {
|
||||
return fetch(path, {
|
||||
method,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.catch(error => console.error("Error:", error));
|
||||
};
|
||||
|
||||
export const addToIPFS = (yourJSON: object) => fetchFromApi({ path: "/api/ipfs/add", method: "Post", body: yourJSON });
|
||||
|
||||
export const getMetadataFromIPFS = (ipfsHash: string) =>
|
||||
fetchFromApi({ path: "/api/ipfs/get-metadata", method: "Post", body: { ipfsHash } });
|
||||
Reference in New Issue
Block a user