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

    Function createHttpBridge

    • createHttpBridge — fetch-based transport plugin.

      Intercepts matching commands and forwards them to the backend as JSON. The backend receives { command, target, payload } and returns { ok, state, error }.

      Features: multi-source CSRF token reading (meta tag / cookie / hidden input), automatic CSRF-expiry refresh on HTTP 419 (Laravel Sanctum convention by default, configurable for other frameworks), session-expiry detection on 401, Retry-After header support, request timeout, per-call AbortSignal, jittered exponential backoff.

      Parameters

      Returns AsyncPlugin

      const bus = createAsyncCommandBus()
      bus.use(createHttpBridge({ endpoint: '/api/vc', csrf: true, retry: 2 }))

      await bus.dispatch('cartAdd', product, { quantity: 2 })