Expand all

RESTClient

Constructor

new RESTClient(endpoint, agent) #

Constructs a new agent for making HTTP requests to the MediaWiki REST API. The agent acts like a browser session and has its own cookie jar. Pass in an optional supertest agent with user session information (cookie jar) for the client to behave as a logged in user.

Parameters:

Name Type Default Description
endpoint string rest.php/v1

REST endpoint path

agent Object null

supertest agent

Source:

Constructs a new agent for making HTTP requests to the MediaWiki REST API.

Methods

del(endpoint, params, headers) → {Promise.<any>} #

Constructs a DELETE request and returns the corresponding supertest Test object

Parameters:

Name Type Description
endpoint string
params Object
headers Object
Source:

Returns:

Type
Promise.<any>

Constructs a DELETE request and returns the corresponding supertest Test object

.

get(endpoint, params, headers) → {Promise.<any>} #

Constructs a GET request and returns the corresponding supertest Test object

Parameters:

Name Type Description
endpoint string
params Object | null
headers Object
Source:

Returns:

Type
Promise.<any>

Constructs a GET request and returns the corresponding supertest Test object

.

post(endpoint, params, headers) → {Promise.<any>} #

Constructs a POST request and returns the corresponding supertest Test object

Parameters:

Name Type Description
endpoint string
params Object | string
headers Object
Source:

Returns:

Type
Promise.<any>

Constructs a POST request and returns the corresponding supertest Test object

.

put(endpoint, params, headers) → {Promise.<any>} #

Constructs a PUT request and returns the corresponding supertest Test object

Parameters:

Name Type Description
endpoint string
params Object | string
headers Object
Source:

Returns:

Type
Promise.<any>

Constructs a PUT request and returns the corresponding supertest Test object

.

request(endpoint, method, params, headers) → {Promise.<any>} #

Constructs an HTTP request to the REST API and returns the corresponding supertest Test object, which behaves like a superagent Request. It can be used like a Promise that resolves to a Response.

Call end(), then(), or use await to send the request.

Parameters:

Name Type Description
endpoint string
method string
params Object | string
headers Object
Source:

Returns:

Type
Promise.<any>

Constructs an HTTP request to the REST API and returns the corresponding supertest Test object, which behaves like a superagent Request.