- Description:
The core/fetch module allows you to make web service requests to the Moodle API.
- Source:
- Copyright:
- Andrew Lyons
- Andrew Lyons
- License:
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
The core/fetch module allows you to make web service requests to the Moodle API.
Example
import Fetch from 'core/fetch';
const result = Fetch.performGet('mod_example', 'animals', { params: { type: 'mammal' } });
result.then((response) => {
// Do something with the Response object.
})
.catch((error) => {
// Handle the error
});
Classes
Methods
(static) performDelete(component, action, params) → {Promise.<Response>}
- Description:
Make a request to the Moodle API.
- Source:
Parameters:
Name | Type | Description | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
component |
string | The frankenstyle component name |
|||||||||||||||
action |
string | The component action to perform |
|||||||||||||||
params |
object |
Properties
|
Returns:
A promise that resolves to the Response object for the request
- Type
- Promise.<Response>
(static) performGet(component, action, params) → {Promise.<Response>}
- Description:
Make a request to the Moodle API.
- Source:
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
component |
string | The frankenstyle component name |
||||||||||
action |
string | The component action to perform |
||||||||||
params |
object |
Properties
|
Returns:
A promise that resolves to the Response object for the request
- Type
- Promise.<Response>
(static) performHead(component, action, params) → {Promise.<Response>}
- Description:
Make a request to the Moodle API.
- Source:
Parameters:
Name | Type | Description | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
component |
string | The frankenstyle component name |
||||||||||
action |
string | The component action to perform |
||||||||||
params |
object |
Properties
|
Returns:
A promise that resolves to the Response object for the request
- Type
- Promise.<Response>
(static) performPatch(component, action, params) → {Promise.<Response>}
- Description:
Make a PATCH request to the Moodle API.
- Source:
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
component |
string | The frankenstyle component name |
||||||
action |
string | The component action to perform |
||||||
params |
object |
Properties
|
Returns:
A promise that resolves to the Response object for the request
- Type
- Promise.<Response>
(static) performPost(component, action, params) → {Promise.<Response>}
- Description:
Make a request to the Moodle API.
- Source:
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
component |
string | The frankenstyle component name |
||||||
action |
string | The component action to perform |
||||||
params |
object |
Properties
|
Returns:
A promise that resolves to the Response object for the request
- Type
- Promise.<Response>
(static) performPut(component, action, params) → {Promise.<Response>}
- Description:
Make a request to the Moodle API.
- Source:
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
component |
string | The frankenstyle component name |
||||||
action |
string | The component action to perform |
||||||
params |
object |
Properties
|
Returns:
A promise that resolves to the Response object for the request
- Type
- Promise.<Response>
(async, static) request(component, action, params) → {Promise.<Response>}
- Description:
Make a single request to the Moodle API.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
component |
string | The frankenstyle component name |
||||||||||||||||||||
action |
string | The component action to perform |
||||||||||||||||||||
params |
object |
Properties
|
Returns:
A promise that resolves to the Response object for the request
- Type
- Promise.<Response>