Package to format service requests in Moodle web service format
npm install moodle-web-service-clientpackage.json first with
npm init command.
npm install command:
console
$ npm install moodle-web-service-client
`
Debug errors Information
To activate debug options.
Go to moodle -> site administration -> developer -> debugging
In debugging messages select developer options.
Examples
$3
If you want to use the default method (POST) you can use the following example.
`ts
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],
},
},
});
`
$3
If you want to use another methods like POST, PUT, DELETE, PATCH, etc. You can use the method property.
`ts
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',
});
``
Hector L. Arrechea 💻 📖 🚇 ⚠️ |