From e8be8df5bac634c80f79b21815f75c4c3fa1d271 Mon Sep 17 00:00:00 2001 From: meirzamoodle Date: Thu, 19 Nov 2026 15:47:07 +0700 Subject: [PATCH] MDL-89243 [docs] Document the core/fetch rejection change Failed fetch requests now reject with the Response instead of its status text. Explain the change and show how to handle both forms. --- docs/devupdate.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/devupdate.md b/docs/devupdate.md index fb7be5d96..cbb748354 100644 --- a/docs/devupdate.md +++ b/docs/devupdate.md @@ -16,3 +16,22 @@ This page highlights the important changes that are coming in Moodle 6.0 for dev The long-deprecated `$CFG->httpswwwroot` has been removed. It has been an alias for `$CFG->wwwroot` since Moodle 3.4, and any remaining usage in third-party code should be replaced with `$CFG->wwwroot` + +## Fetch requests reject with the Response + + + +The `core/fetch` module now rejects a failed request with its `Response` object instead of the response's status text. This gives callers access to the status, headers and body of the error response. + +This is a breaking change for any code which uses the rejection reason as a string. Code which must work on both older and newer versions of Moodle can check the type of the reason: + +```js +import Fetch from 'core/fetch'; + +Fetch.performGet('mod_example', 'animals') + .catch((reason) => { + // Moodle 6.0 and later reject with the Response. Earlier versions reject with its status text. + const message = reason instanceof Response ? reason.statusText : reason; + throw new Error(message, {cause: reason}); + }); +```