Back

[SOLVED] Error with client.setEndpoint

  • 0
  • Web
killerthief
22 Aug, 2023, 20:44

import { Client, Account } from "appwrite"; import { ID } from "appwrite";

export function AuthWriter( email, password, name){

TypeScript
try{

    const client = new Client();

    const account = new Account(client);

    
    console.log("Client and user are initialized")
    client.setEndpoint(process.env.APP_WRITER_ENDPOINTT).setProject(process.env.APP_WRITER_PROJECT_ID);

    const promise = account.create({userId:ID.unique(),email:email,password:password,name:name});

    promise.then(function (response) {
        console.log(response); // Success
    }, function (error) {
        console.log(error); // Failure
    });
    

}
catch(error){

    console.error(error)
}

} thisis the code

TL;DR
There was an error with the client.setEndpoint function due to an issue with the env file. The error was fixed by removing an extra "T" from the value passed to the setEndpoint method.
killerthief
22 Aug, 2023, 20:44

the error

killerthief
22 Aug, 2023, 20:44

peError: Cannot read properties of undefined (reading 'replace') at Client.setEndpoint (webpack-internal:

Binyamin
22 Aug, 2023, 22:51

Maybe you've extra T here

TypeScript
process.env.APP_WRITER_ENDPOINTT
Binyamin
22 Aug, 2023, 22:52

It seems like the value you've passed to the setEndpoint method is undefined

Drake
23 Aug, 2023, 00:05

Btw, it's best to use 3 back ticks with multi-line code. See https://www.markdownguide.org/extended-syntax/#syntax-highlighting

killerthief
23 Aug, 2023, 18:11

Thanks

killerthief
23 Aug, 2023, 18:11

there seems some error with my env fiel

Binyamin
23 Aug, 2023, 18:24

Is it working now?

killerthief
23 Aug, 2023, 19:08

yes , works great. the error was due to env file

killerthief
23 Aug, 2023, 19:08

Thanks alot

Drake
23 Aug, 2023, 19:35

[SOLVED] Error with client.setEndpoint

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