Back

Need help with web sdk

  • 0
  • Web
Mattias Aabmets
17 Apr, 2023, 10:39

You always have to be mindful whether the server expects either a GET or a POST request, because using the incorrect request type will break things.

TL;DR
User is experiencing an error with a web SDK related to network requests. They mention that the error is not breaking their app due to proper error handling. Other users suggest checking for logged-in status and review the implementation and context creation. One user shares their React course capstone project for reference. A possible suggestion is to check for a CORS error. User confirms using the Appwrite web SDK and provides their code snippet. The issue persists despite their efforts. Another user suggests catching Appwrite-specific errors. Lastly, it is mentioned to ensure using the correct request type (GET or POST) when communicating with the server.
Mattias Aabmets
17 Apr, 2023, 10:40

Also, you can catch Appwrite-specific errors by attaching .catch((e) => console.log(e)) to the promise

Pradip Chaudhary
17 Apr, 2023, 13:26

Hey, thanks for responding Mattias

Pradip Chaudhary
17 Apr, 2023, 13:27

But I'm still facing the issue

Pradip Chaudhary
17 Apr, 2023, 13:27

As you can see this is my code snippet

Pradip Chaudhary
17 Apr, 2023, 13:27
Pradip Chaudhary
17 Apr, 2023, 13:27

But still I'm getting the error

Pradip Chaudhary
17 Apr, 2023, 13:27
Pradip Chaudhary
17 Apr, 2023, 13:27

I'm using the web sdk of appwrite

Mattias Aabmets
17 Apr, 2023, 15:03

Well im out of ideas. Maybe a CORS error?

Pradip Chaudhary
17 Apr, 2023, 15:09

but when the user exists it doesn't give error

Mattias Aabmets
17 Apr, 2023, 15:46

Take a look at my React course capstone project at https://github.com/aabmets/react-capstone-course

Mattias Aabmets
17 Apr, 2023, 15:47

which uses next.js + appwrite

Mattias Aabmets
17 Apr, 2023, 15:47

Take a look at the pages/account.tsx file and understand how it works

Mattias Aabmets
17 Apr, 2023, 15:48

also take a look at how the appwrite context is created

Mattias Aabmets
17 Apr, 2023, 15:48

my implementation works

Arth
17 Apr, 2023, 16:04

where are you using catch()?

Arth
17 Apr, 2023, 16:04

getSession does throw error when the user isn't logged in and that's expected

Arth
17 Apr, 2023, 16:04

that's how you know that user is not logged in

Arth
17 Apr, 2023, 16:05

your app looks okay what's the issue? the network request error in red that you're getting in console won't break your app since you're catching it

Pradip Chaudhary
18 Apr, 2023, 07:59

yaa i got it now

Pradip Chaudhary
18 Apr, 2023, 08:00

but will it also be shown in production?

Arth
18 Apr, 2023, 08:02

yes it will be

Arth
18 Apr, 2023, 08:02

and that's how it's supposed to be

Pradip Chaudhary
20 Apr, 2023, 04:38

okay thanks

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