Moodle REST client for NodeJS
Information
Node.js module for Moodle Rest Service integration
Setup
Npm
npm install moodle-rest-client --save
Yarn
yarn add moodle-rest-client
Usage
Instance
const MoodleRestClient = //Default use. Results in: http://your-moodle-url.comconst client = 'your-moodle-url.com' 'your-moodle-token'//Using https. Results in: http://your-moodle-url.comconst client = 'your-moodle-url.com' 'your-moodle-token' protocol: 'https'//Using diferent port. Results in: http://your-moodle-url.com:8080const client = 'your-moodle-url.com' 'your-moodle-token' port: 8080//Using subdirectory. Results in: http://your-moodle-url.com/moodleconst client = 'your-moodle-url.com' 'your-moodle-token' subdirectory: 'moodle'//Using all together. Results in: https://your-moodle-url.com:8080/moodleconst client = 'your-moodle-url.com' 'your-moodle-token' protocol: 'https' port: 8080 subdirectory: 'moodle'
Request
The method client.send
expects three params:
- wsFunction: Moodle webservice function name
- Key: Moodle webservice function parameter key
- Value: Moodle webservice function parameter value
Get user sample
client
Create user sample
let data = username: 'username' password: 'Strong@pass123' firstname: 'Firstname' lastname: 'Lastname' email: 'user@provider.com'client