Package to format service request in Moodle web service format
This is a Node.js module available through the npm registry.
Before installing, download and install Node.js.
If this is a brand new project, make sure to create a package.json
first with
the npm init
command.
Installation is done using the
npm install
command:
$ npm install moodle-web-service-client
To activate debug options.
Go to moodle -> site administration -> developer -> debugging
In debugging messages select developer options.
If you want to use the default method (POST) you can use the following example.
import {moodleClient} from "moodle-web-service-client";
const response = await moodleClient({
urlRequest: {
rootURL: 'http://localhost/moodle',
token: 'aeb315e6dd3affc18352fe46124cdd48',
webServiceFunction: 'core_course_get_courses',
},
content: {
options: {
ids: [1, 2, 3],
},
},
});
If you want to use another methods like POST, PUT, DELETE, PATCH, etc. You can use the method property.
import {moodleClient} from "moodle-web-service-client";
const response = await moodleClient({
urlRequest: {
rootURL: 'http://localhost/moodle',
token: 'aeb315e6dd3affc18352fe46124cdd48',
webServiceFunction: 'core_course_get_courses',
},
content: {
options: {
ids: [1, 2, 3],
},
},
method: 'GET',
});
Looking to contribute? Look for the label.
Please file an issue for bugs, missing documentation, or unexpected behavior.
Please file an issue to suggest new features. Vote on feature requests by adding a 👍. This helps maintainers prioritize what to work on.
Hector L. Arrechea 💻 📖 🚇 |