Back

Throws error , after creating the user

  • 0
  • Web
killerthief
27 Aug, 2023, 20:13

It creats the user then throws the error not sure why

TypeScript
const SignUp = async (email,password,name) => {
        setLoading(true)
        console.log("Entered the sign up process... ")
        const promise =  await account.create(ID.unique(),email,password,name)
        console.log(promise);
        if(promise){
            console.log("Can login in")
            await setDataprofile({
                id: promise.$id,
                name: promise.name,
                address:"",
                phonenumber:1,
                gender:"",
                profileimage:""

        })
        const response = await axios.post("/api/users/Userprofile",dataprofile)
        console.log(response)
        }
        
        setLoading(false);
    }
TL;DR
The user profile API is throwing an error after creating the user. There seems to be a duplicate create request going out, which is causing the error. The solution is to check the network tab and remove any duplicate create requests. Here is the updated code: ```js const SignUp = async (email, password, name) => { setLoading(true) console.log("Entered the sign up process... ") const promise = await account.create(ID.unique(), email, password, name) console.log(promise); if (promise) { console.log("Can login in") await setDataprofile({ id:
ideclon
27 Aug, 2023, 20:14

Looks like it might be trying to make the create request twice

ideclon
27 Aug, 2023, 20:14

Can you check the network tab?

ideclon
27 Aug, 2023, 20:15

Is it possible you have the account.create again somewhere?

killerthief
27 Aug, 2023, 20:15

nope

killerthief
27 Aug, 2023, 20:16

all , I am trying to do is once you created the account , I wan the id and name to store it in the db I created

killerthief
27 Aug, 2023, 20:16
TypeScript
const SignUp = async (email,password,name) => {
        setLoading(true)
        console.log("Entered the sign up process... ")
        const promise =  await account.create(ID.unique(),email,password,name)
        console.log(promise);
        if(promise.$id){
            console.log("Can login in")
            setDataprofile({
                id: promise.$id,
                name: promise.name,
                address:"",
                phonenumber:1,
                gender:"",
                profileimage:""

        })
        const response = await axios.post("/api/users/Userprofile",dataprofile)
        console.log(response)
        }
        
        setLoading(false);
    } ```
ideclon
27 Aug, 2023, 20:16

Can you check the network tab - is there another create request going out?

killerthief
27 Aug, 2023, 20:17

will it be named ? as account ?

killerthief
27 Aug, 2023, 20:18

Now , I am rate limited on cloud and lcoal

killerthief
27 Aug, 2023, 20:18

😒

ideclon
27 Aug, 2023, 20:20

I don’t know - it’ll be a second request out to the /account endpoint

killerthief
27 Aug, 2023, 20:22

one sec let me share the network

killerthief
27 Aug, 2023, 20:24
killerthief
27 Aug, 2023, 20:24

These are the request

Drake
30 Aug, 2023, 01:53

So it seems the user profile API is throwing an error. What's the code for that?

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