Advertisement
yarin0600

Untitled

Jan 11th, 2024
959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const pinFileToIPFS = async () => {
  2.     try {
  3.       const formData = new FormData();
  4.       formData.append('file', await fetch('./assets/Pinnie.png').then((res) => res.blob()));
  5.  
  6.       // Now you can use formData for your API request, e.g., send it to the server or IPFS
  7.  
  8.       // Example using fetch:
  9.       // const response = await fetch('your-api-endpoint', {
  10.       //   method: 'POST',
  11.       //   body: formData,
  12.       // });
  13.  
  14.       // Handle the response as needed
  15.     } catch (error) {
  16.       console.error('Error pinning file to IPFS:', error);
  17.     }
  18.   };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement