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 |
Methods
del(endpoint, params, headers) → {Promise.<*>}
Constructs a DELETE request and returns the corresponding supertest Test object
.get(endpoint, params, headers) → {Promise.<*>}
Constructs a GET request and returns the corresponding supertest Test object
.post(endpoint, params, headers) → {Promise.<*>}
Constructs a POST request and returns the corresponding supertest Test object
.put(endpoint, params, headers) → {Promise.<*>}
Constructs a PUT request and returns the corresponding supertest Test object
.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 |
Returns:
- Type
- Promise.<*>