vapor-chamber API reference - v1.3.0
    Preparing search index...

    Function createHttpClient

    • createHttpClient — multi-method HTTP client with interceptors, caching, deduplication, safe mode, and file download.

      Aligned with useFetch (2026-02-05A) patterns. Framework-agnostic — no Vue imports.

      Parameters

      Returns HttpClient

      const http = createHttpClient({ baseURL: '/api', csrf: true });

      // All methods
      const users = await http.get('/users', { params: { page: 1 } });
      await http.post('/cart', { itemId: 1, qty: 2 });
      await http.put('/cart/1', { qty: 5 });
      await http.delete('/cart/1');

      // Safe mode — never throws
      const result = await http.safe.post('/login', credentials);
      if (result.error) console.log(result.error.message);

      // File download
      await http.download('/export/csv', 'products.csv');

      // Interceptors
      http.interceptors.request.use((config) => { config.headers = { ...config.headers, 'X-Custom': '1' }; return config; });

      // Create scoped instance
      const adminHttp = http.create({ baseURL: '/admin/api', headers: { 'X-Admin': 'true' } });