import { SDK, HttpClient } from '@cryptorubic/sdk-lite';
const fetchClient: HttpClient = {
async get(url, options = {}) {
const searchParams = new URLSearchParams(
Object.entries(options.params ?? {}).map(([k, v]) => [k, String(v)])
);
const fullUrl = searchParams.size ? `${url}?${searchParams}` : url;
const res = await fetch(fullUrl, { headers: options.headers });
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
},
async post(url, body, options = {}) {
const res = await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...options.headers },
body: JSON.stringify(body),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
return res.json();
},
};
const sdk = await SDK.create({ referrer: 'my-app' }, fetchClient);