Rank 5: Hypervisor
I am using ID.unique() as I expected it will generate unique ID
Votes
1
Replies
24
Participants
Unknown
Messages
25
Rank 5: Hypervisor
I am using ID.unique() as I expected it will generate unique ID
Rank 5: Hypervisor
Yet this is the declaration of it
Rank 5: Hypervisor
Maybe that is the problem
Rank 5: Hypervisor
Ok no that is not the issue, I still get anonymous users created
Rank 5: Hypervisor
From console logs
"{\"email\": \"user@example.com\",\"password\": \"example\",\"name\": \"User example\"}"PAYLOAD PARSED{"email": "user@example.com","password": "example","name": "User example"}USER_ID6j4o3p1vi8eqtg6hrxag```
From function response `{"response":{"statusCode":200,"body":{"$id":"6j4o3p1vi8eqtg6hrxag","$createdAt":"2023-07-21T12:33:01.097+00:00","$updatedAt":"2023-07-21T12:33:01.097+00:00","name":"","password":"","hash":"argon2","hashOptions":{"memoryCost":2048,"timeCost":4,"threads":3},"registration":"2023-07-21T12:33:01.096+00:00","status":true,"passwordUpdate":"","email":"","phone":"","emailVerification":false,"phoneVerification":false,"prefs":[]}},"payload":"\"{\\\"email\\\": \\\"user@example.com\\\",\\\"password\\\": \\\"example\\\",\\\"name\\\": \\\"User example\\\"}\""}`Rank 5: Hypervisor
Idk why this is happening
Rank 5: Hypervisor
I still can't figure out why is it creating anonymous user :x
Rank 5: Hypervisor
These are my console log results
PAYLOAD UNPARSED
"{email: \"user@example.com\",\"password\": \"example\",\"name\": \"User example\"}"
PAYLOAD PARSED
{email: "user@example.com","password": "example","name": "User example"}
USER_ID
msm2ajmpvwn3nh7afdj0
USER_EMAIL
USER_PASSWORD
USER_NAME
These are my console logs
const payload: IUser = JSON.parse(req.payload);
console.log('PAYLOAD PARSED')
console.log(payload)
const userId = ID.custom(generateUniqueId());
console.log('USER_ID')
console.log(userId)
console.log('USER_EMAIL')
console.log(payload.email)
console.log('USER_PASSWORD')
console.log(payload.password)
console.log('USER_NAME')
console.log(payload.name)
Rank 5: Hypervisor
So for some reason payload variables aren't fetched
in here, don't escape/wrap with quotes. it should be:
{"email": "user@example.com","password": "example","name": "User example"}
Rank 5: Hypervisor
This is parsed payload.
While I am sending stringified and then parsing it - which is supposedly okay based on the console logs?
And I console.log parsed one, the one you wrote, and it doesn't return property values
no you shouldn't be escaping stuff when putting it in the console
Rank 5: Hypervisor
ok, so as I am going to be sending stringified payload from the client, then I can't test stringified payload via console 😦
no, it's because in the console it's already a string...you're so you're stringifying it again by putting:
"{\"email\": \"user@example.com\",\"password\": \"example\",\"name\": \"User example\"}"
Rank 5: Hypervisor
I see now, that was really confusing, didn't know it was a string already as I didn't see any note about it.
Thanks for helping out, it works fine now
a note...like the example below?
Rank 5: Hypervisor
Maybe this? Not sure if it would be helpful to have this note in the console as well. I missed it :X
did you look right under the input box for the custom data in the console?
Rank 5: Hypervisor
Yes. But that also didn't indicate I can't really put stringified payload in there 🙂
And as I missed the docs I sent, took a while to figure out.
Another thing that might be good is interlinking appwrite console with the documentation.
But that would be to the UI people to decide, I can't really tell where would be good places to do that
if you put a stringified payload, your code would need to parse it twice
Rank 5: Hypervisor
Like placing links to docs, or making hover effect labels that would give more information about something in the console
Rank 5: Hypervisor
Yeah 😅
Either way, it works now and I can continue working on my app 😄
[SOLVED] Appwrite function - anonymous user created even with payload present