Http Client for JS - munichbughunter/SevenFacette GitHub Wiki

Configuration

The easiest way is to create a configuration file. For every rest-client create one named section in the configuration file. Then access the configuration in the classes constructor.

var myHttpClient = new http.createHttpClient("httpClientNameFromConfig")

All configurations will be loaded in the background and be used as soon as the client is instantiated.

Requests

Currently GET, HEAD, POST, PUT, PATCH and DELETE requests are supported. You can send

  • Strings (including graphQL, JSON, XML)
  • Byte Array
  • multipart body For strings add the used content-type, e.g. CONTENTTYPES.APPLICATION_JSON.

Headers

All requests need an HttpHeader-object. This object is a mutable map that holds string keys and lists of string values.

Response

If the requests can be performed a HttpResponse-object will be returned - otherwise, an exception is thrown. This object consists of

  • body
  • status
  • headers The headers are a map of string keys and lists of string values

Example

// First create a client
var myHttpClient = new http.createHttpClient("httpClientNameFromConfig")  

// Simple get requests
var httpResponse = await myHttpClient.get("/path/to/endpoint")

⚠️ **GitHub.com Fallback** ⚠️