RESTClient(endpoint, agent)

Show:

new RESTClient(endpoint, agent)

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

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:

Methods

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

Constructs a DELETE request and returns the corresponding supertest Test object

.

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.<*>

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

Constructs a GET request and returns the corresponding supertest Test object

.

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.<*>

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

Constructs a POST request and returns the corresponding supertest Test object

.

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.<*>

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

Constructs a PUT request and returns the corresponding supertest Test object

.

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.<*>

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

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

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.<*>