- Source:
Members
(static) RestfulJsonClient
This class provides a dedicated client for restful operations against an API via JSON payloads and responses.
Internally this implementation uses createJsonRequest to actually request stuff, while this class is a wrapper, providing central configuration, such as a base URL and options like credentials, as well as standard methods for HTTP verbs and setup things like setting headers.
See class documentation below for details.
Example
const client = new RestfulJsonClient('https://jsonplaceholder.typicode.com', {credentials : 'include'});
const postJson = await client
.path('/posts')
.params({
ids : [1, 2],
q : 'lorem'
})
.data({
title : 'foo',
body : 'bar',
userId : 1,
})
.post()
;