logo
search
Office Settings & Configuration

Fix 'fetch is not defined' Error in Excel Office Add-ins

Kushani NimanthikaKushani Nimanthika Sep 30, 2026 868 views

Question details

Developers need to resolve a 'fetch is not defined' JavaScript error encountered in taskpane.js while building an Excel Office Add-in.

How to Fix 'fetch is not defined' in an Excel Office Add-in
Product
Microsoft Excel Office Add-ins
Device & OS
not provided
Scenario
Developing an Office Add-in using Microsoft's guidance for single sign-on (SSO) or nested app authentication, resulting in runtime execution failures.
Observed behavior
The add-in fails to execute network requests, and the developer console throws a 'fetch is not defined' error because the runtime environment does not natively support the Fetch API.
Before you start

Ensure you know which webview engine (such as Edge WebView2 or Internet Explorer 11) your specific version of Microsoft Office relies on to render add-ins, as this dictates your JavaScript API support.

Solution 1Recommended

Verify Browser Environment and Add Fetch Polyfills

Use a JavaScript polyfill to add Fetch API support for older Office embedded browser runtimes that do not natively support it.

Microsoft Office Add-ins are rendered using an embedded web browser control. While modern Office setups use Chromium-based WebView2, older installations use Trident (Internet Explorer 11), which lacks native support for the Fetch API. Injecting a polyfill ensures cross-version compatibility.

1
Install a fetch polyfill

Open your terminal, navigate to your Office Add-in project folder, and run a package manager command like 'npm install whatwg-fetch' to download the polyfill.

2
Import the polyfill in your code

Open your 'taskpane.js' file or the main JavaScript entry point of your add-in, and add 'import "whatwg-fetch";' at the very top of the file.

3
Update your bundler configuration

If you are using Webpack or Rollup, ensure your configuration is set to include imported polyfills in the final output bundle targeted for the browser.

4
Test the add-in in the desktop client

Run 'npm start' to sideload the add-in into the Excel desktop application and verify that the authentication network requests now succeed without the error.

Verify Browser Environment and Add Fetch Polyfills
Alternative to Polyfills: If you prefer not to use polyfills, you can rewrite your network requests using 'XMLHttpRequest' or third-party libraries like Axios, which work out-of-the-box on older runtimes.
Free Microsoft Office alternative

Looking for a Developer-Friendly, Lightweight Office Suite?

If complex add-in configurations and legacy runtime compatibility issues in Microsoft Office are slowing down your workflow, consider trying WPS Office. It delivers a fast, stable, and highly compatible environment for all your spreadsheet tasks without the heavy overhead.

  1. 1. Download the installer: Visit the official WPS Office website and download the free installer for your operating system.
  2. 2. Install WPS Office: Run the setup file and follow the quick on-screen instructions to complete the installation.
  3. 3. Open your files instantly: Launch WPS Spreadsheet and directly open your existing .xlsx files without worrying about formatting loss.
Seamless format compatibility with Microsoft Excel (.xlsx), Word (.docx), and PowerPoint (.pptx).Free, lightweight, and consumes significantly fewer system resources than standard office suites.Familiar tabbed user interface, ensuring zero learning curve for smooth migration.Avoid complex legacy browser runtime issues while managing large datasets and everyday document workflows.
microsoft office alternative - wps office

Frequently Asked Questions

Why does 'fetch is not defined' happen in desktop Excel but not on the web?

Excel on the web runs inside your standard modern web browser (like Chrome or Edge), which natively supports the Fetch API. The desktop version of Excel may rely on an older embedded web control, such as Internet Explorer 11, which does not support modern JavaScript APIs without polyfills.

How do I check which browser engine my Office Add-in is using?

The browser engine depends on your Windows version and Office build. You can determine this by opening your add-in's developer tools and checking the 'navigator.userAgent' string in the console. Modern Microsoft 365 environments generally use Edge WebView2 (Chromium), while older retail versions fall back to Trident.

Can I use Axios instead of Fetch to fix this error?

Yes. Axios is a popular HTTP client that uses 'XMLHttpRequest' under the hood rather than the Fetch API. Because 'XMLHttpRequest' is supported even in older Internet Explorer 11 runtimes, replacing fetch with Axios will bypass the 'fetch is not defined' error completely.