Skip to main content

strapi.fetch uses the native fetch() API

In Strapi v5, the strapi.fetch object is now wrapping node Fetch API instead of node-fetch.

Breaking change description

In Strapi v4

Strapi.fetch wrapped node-fetch’s fetch() and accepted the same parameters.

In Strapi v5

The node-fetch module is not used anymore. strapi.fetch calls the native fetch() method.

Migration

Notes

  • The parameters are mostly compatible but there are some differences.

Manual procedure

If your Strapi v4 code passed the timeout parameter to strapi.fetch, replace it with a signal property as follows:

In Strapi v4

strapi.fetch(url, {
method: 'POST',
body,
headers,
timeout: 1000,
}); // accepts the type RequestInit from node-fetch

In Strapi v5

strapi.fetch(url, {
method: 'POST',
body,
headers,
signal: AbortSignal.timeout(1000)
}); // accepts the type RequestInit native to Node