v1.4.2

Migration Guides

Migrating from Native fetch

Before (Raw Fetch):

ts
const params = new URLSearchParams({ type: 'admin' }); const res = await fetch(`/api/users?\${params.toString()}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ active: true }) }); if (!res.ok) throw new Error("Status " + res.status); const data = await res.json();

After (BoltFetch):

ts
const res = await boltfetch.post('/api/users', { params: { type: 'admin' }, body: { active: true } }); if (!res.success) return; // handles non-2xx statuses automatically const data = res.data;

Migrating from Axios

Before (Axios):

ts
try { const response = await axios.get('/api/data'); setData(response.data); } catch (error) { if (axios.isAxiosError(error)) { console.error(error.response?.data); } }

After (BoltFetch):

ts
const res = await boltfetch.get('/api/data'); if (res.success) { setData(res.data); } else { console.error(res.moreInfo); }