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()-> setsContent-Type: application/x-www-form-urlencodedaccept(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 topost/put/patch.- The
getmethod accepts a secondparamsargument in signature, but current implementation useswithQueryParameters(...)for query injection. - Socialite provider drivers use this HTTP client for OAuth calls.
Summary
- Use
Httpas a fluent Axios wrapper. - Prefer
withQueryParameters,withHeaders,acceptJson, andasFormbefore request verbs. - Rely on automatic reset for clean per-request state.
