AUR5000

Error Message

AUR5000: Could not resolve fetch function. Please provide a fetch function implementation or a polyfill for the global fetch function.

Description

This error occurs when the Aurelia Fetch Client cannot find a fetch function implementation. The fetch client requires either:

  1. A global fetch function (available in modern browsers and Node.js 18+)

  2. A polyfill for environments that don't support fetch natively

  3. A custom fetch implementation provided during configuration

Common Scenarios

Node.js Environments (pre-18)

// Node.js versions before 18 don't have global fetch
import { HttpClient } from '@aurelia/fetch-client';

// This will throw AUR5000
const client = new HttpClient();

Server-Side Rendering

Solutions

Node.js 18+ includes global fetch support:

2. Install a Fetch Polyfill

For older environments, install a fetch polyfill:

3. Configure Custom Fetch Implementation

Provide a custom fetch function during HttpClient configuration:

4. Dependency Injection Configuration

Configure the fetch function at the container level:

Example: Complete SSR Setup

Debugging Tips

  1. Check Environment: Verify if your runtime environment supports global fetch

  2. Import Order: Ensure polyfills are imported before any Aurelia code

  3. SSR Context: Pay special attention to server-side rendering scenarios

  4. Node.js Version: Consider upgrading to Node.js 18+ for native fetch support

Last updated

Was this helpful?