Back

[CLOSED] AppwriteException: XMLHttpRequest is not defined

  • 1
  • Functions
  • Web
  • Cloud
timo
8 Dec, 2023, 10:21

Hi, I'm developing a Chrome Extension using Svelte and Appwrite. However, when I try to execute a cloud Function, I always get the following error: AppwriteException: XMLHttpRequest is not defined

This is my code try { // Verify tabs is not empty if (!tabs || tabs.length === 0) { throw new Error("Tabs is empty"); }

TypeScript
        // Verify tabs is not empty
        if (tabs.length > 100) {
            throw new Error("Tabs is too long");
        }

        const execution = await this.functions.createExecution(
            'FUNCTION-ID',
            JSON.stringify({ tabs }),
            true,
            '/',
            'POST',
            { 'Access-Control-Allow-Origin': '*' }
        )

        console.log(execution);

        return execution;
    } catch (error: any) {
        console.error("Error creating execution", error);
        throw error;
    }

I've read that Chrome Extensions only support Fetch, does the Appwrite SDK still use XHR? Any Ideas why this might be happening? Thanks :)

TL;DR
The user is experiencing an error in their Chrome Extension code using Svelte and Appwrite. The error message they receive is "AppwriteException: XMLHttpRequest is not defined." They mention that Chrome Extensions only support Fetch and ask if Appwrite SDK still uses XHR. They are seeking ideas for why this error might be happening. Solution: The user was able to solve the issue by overriding the cross-fetch version to 4.0. However, they mentioned that this solution brings its own challenges, so they decided to use normal fetch instead of the SDK for now.
Drake
8 Dec, 2023, 10:35
timo
8 Dec, 2023, 19:57

Thank you so much, that seemed to be the Issue. I was able to solve it by overriding the cross-fetch version to 4.0, but that brings it's own challenges. So I think for now I'm just gonna use normal fetch instead of the SDK.

Drake
9 Dec, 2023, 06:49

[CLOSED] AppwriteException: XMLHttpRequest is not defined

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more