Rank 1: Thread
So I'm using appwrite for the first time and am trying to insert something to my db, however, I keep getting this error in the console:
AppwriteException: The current user is not authorized to perform the requested action.at Client.<anonymous>
I'm inserting the data without any user auth on the website - do I have to make an auth system? Or is there just something wrong with my api keys?
Also here's my code (I'm using SvelteKit):
<script> import { Client, Databases, ID } from "appwrite"; import { client } from "$lib/appwrite"; import { PUBLIC_APPWRITE_DB, PUBLIC_APPWRITE_COLLECTION, } from "$env/static/public"; let val= "";
const databases = new Databases(client); function submit() { const promise = databases.createDocument( PUBLIC_APPWRITE_DB, PUBLIC_APPWRITE_COLLECTION, ID.unique(), { url: "test data", hash: "test data" }, );
promise.then( function (response) { console.log(response); }, function (error) { console.log(error); }, ); }</script> <form on:submit={(e) => { e.preventDefault(); submit(); }} > <input bind:value={val} type="text" /> <button type="submit">submit</button> </form>