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 |
Constructs a new agent for making HTTP requests to the MediaWiki REST API.
Methods
Constructs a DELETE request and returns the corresponding supertest Test object
.Constructs a GET request and returns the corresponding supertest Test object
.Constructs a POST request and returns the corresponding supertest Test object
.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:
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.