wala.ts (632B)
1 import { PUBLIC_WALA_URL } from "$env/static/public"; 2 3 export const uploadTextToWala = async (text: string) => { 4 try { 5 const response = await fetch(PUBLIC_WALA_URL, { 6 method: 'PUT', 7 headers: { 8 'Content-Type': 'text/plain' 9 }, 10 body: text 11 }) 12 return response.text() 13 } catch (error) { 14 console.error(error) 15 } 16 } 17 18 export const getText = async (hash: string) => { 19 try { 20 const h = hash.startsWith('0x') ? hash.substring(2) : hash 21 const response = await fetch(`${PUBLIC_WALA_URL}/${h}`) 22 return response.text() 23 } catch (error) { 24 console.error(error) 25 } 26 }