So I'm working through the ideas tutorial and just to be sure I have copied and pasted all the code over and fixed all errors. Now I'm getting a 401 error I've checked that my endpoint and project ID are correct. Should I try using an API key instead?
Would love any help with this
Could you provide your code that is throwing a 401?
Certainly, here it is import { Client, Databases, Account } from "appwrite";
const client = new Client(); console.log('this is the client', client);
client.setEndpoint("https://cloud.appwrite.io/v1") .setProject("67d9e1fa00246f29e7c2");
export const account = new Account(client);
console.log('this is the account', account);
export const databases = new Databases(client); console.log('this is the database', databases);
This is what I'm getting in my browser console ''XHRGET https://cloud.appwrite.io/v1/account [HTTP/2 401 228ms] ''
Can you show me the call you're making to the account? Like maybe account.get()?
I've double checked all my creds are correct and I'm following this tutorial so I know my code is correct had to fix a few minor issues:
Good question, I don't think I can tbh. The code I just provided is doing that under the hood I think
So I've followed the tutorial to the letter and I'm still getting this. Do you think it could have something to do with the order in which I grab things. So there is a login page
But I'm not logged in yet
Maybe it's a silly suggestion
Can you give me the exact error from console, with the stack trace. I suspect it comes from the UserProvider init function.
Here is the title:
GET https://cloud.appwrite.io/v1/account [HTTP/2 401 228ms]
Yea, so this is expected. If the user isn't authenticated and you do account.get() it throws an error.
Here is the header stack trace
Oh shoot it's giving me this Your message could not be delivered. This is usually because you don't share a server with the recipient or the recipient is only accepting direct messages from friends. You can see the full list of reasons here: https://support.discord.com/hc/en-us/articles/360060145013
I see, is this a good sign
https
host
cloud.appwrite.io
filename
/v1/account
Address
172.67.36.127:443
Status
401```'''
Yea, if you see in the code
...
async function init() {
try {
const loggedIn = await account.get();
setUser(loggedIn);
} catch (err) {
setUser(null);
}
}
...
you are catching the error that is thown and setting the user to null
Have you impemented logging in? If so once you login do you still get this issue?
Recommended threads
- Site deployment keeps getting failed
Hi good folks, need a hand with Sites deploy Error on every deploy: Synchronous function execution timed out... duration doesn't exceed 30 seconds [exact log ...
- Relation Question
How do I create a relation from table y to an others x.$id. in my example I have a users table where I use Appwrites unique User IDs and I want other tables fo...
- Unknown attribute type: varchar / text
Since the `string` type is deprecated I tried using `varchar` and `text` in some newer tables, but when running `appwrite pull tables && appwrite types ./src/li...