JCC Express

HTTP Client

Introduction

JCC Express MVC ships a static fluent HTTP client (Http) built on top of Axios:

  • Source: jcc-express-mvc/lib/Http/index.ts
  • Core export: jcc-express-mvc/Core/http

It supports chainable headers/query setup and resets internal state after every request method.


Import

TypeScript

Supported request methods

  • Http.get(url)
  • Http.post(url, data?)
  • Http.put(url, data?)
  • Http.patch(url, data?)
  • Http.delete(url)

Each returns the Axios promise/response.


Fluent configuration

  • withHeaders(headers)
  • withQueryParameters(params)
  • withBody(data, contentType?)
  • asForm() -> sets Content-Type: application/x-www-form-urlencoded
  • accept(contentType)
  • acceptJson()
  • reset()

Example:

TypeScript

POST/PATCH/PUT examples

TypeScript

Query parameter behavior

withQueryParameters(...) appends query strings via URLSearchParams:

TypeScript

State reset behavior

After each verb call (get, post, put, patch, delete), the client calls reset() internally:

  • query params cleared
  • headers cleared
  • body cache cleared

This prevents chained settings from leaking into the next request.


Notes

  • withBody(...) currently stores body metadata and sets content type; pass actual payload directly to post/put/patch.
  • The get method accepts a second params argument in signature, but current implementation uses withQueryParameters(...) for query injection.
  • Socialite provider drivers use this HTTP client for OAuth calls.

Summary

  • Use Http as a fluent Axios wrapper.
  • Prefer withQueryParameters, withHeaders, acceptJson, and asForm before request verbs.
  • Rely on automatic reset for clean per-request state.