Back

Not getting response from appwrite

  • 0
  • Web
Adnan Khan
17 Nov, 2023, 13:05

I was making a client .setEndpoint('https://cloud.appwrite.io/v1') and its not working showing this on clicking this link Error 404 The requested route was not found. Please refer to the API docs and try again. And while open the localhost/3000 getting this error Unhandled Runtime Error

AppwriteException: Network request failed Call Stack AppwriteException node_modules\appwrite\dist\esm\sdk.js (82:0) call/< node_modules\appwrite\dist\esm\sdk.js (404:0) rejected node_modules\appwrite\dist\esm\sdk.js (23:41)

TL;DR
User is experiencing an issue with not getting a response from the Appwrite app. They are receiving a CORS error in the console and a network request failed error. The user has shared their code which includes creating a client with the endpoint set to 'https://cloud.appwrite.io/v1'. There is a suggestion to check if the endpoints were set properly. The user is also getting an error of "Error 404" when clicking on the endpoint link. There is no solution provided in the support thread.
Haimantika
17 Nov, 2023, 13:22

Can you show your entire code?

Haimantika
17 Nov, 2023, 13:22

There are chances that the endpoints weren't set properly

Adnan Khan
17 Nov, 2023, 13:25

import { Client,Account,ID,Databases,Storage } from "appwrite";

const client = new Client(); client .setEndpoint('https://cloud.appwrite.io/v1') .setProject('process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID');

const account = new Account(client) const databases = new Databases(client) const storage = new Storage(client)

export {client,account,databases,storage,ID}

Adnan Khan
17 Nov, 2023, 13:25

This is appwrite file

Adnan Khan
17 Nov, 2023, 13:26

export const getTodosGroupByColumn= async () =>{ const data = await databases.listDocuments( process.env.NEXT_PUBLIC_DATABASE_ID!, process.env.NEXT_PUBLIC_COLLECTION_ID! ) const todos = data.documents

TypeScript
// try{
    const columns = todos.reduce((acc,todo)=>{
        if(!acc.get(todo.status)){
            acc.set(todo.status,{
                id: todo.status,
                todos:[]
            })
        }
        acc.get(todo.status)!.todos.push({
            $id : todo.$id,
            $createdAt:todo.$createdAt,
            title: todo.title,
            status:todo.status,
            //get image if exists on the todo
            ...(todo.image && {image:JSON.parse(todo.image)})
        })
        return acc
    },new Map<TypedColumn,Column>())
    
    console.log(columns)
// }catch (e){
//     console.error(e)
// }

}

Haimantika
17 Nov, 2023, 13:26

What are you trying to do?

Adnan Khan
17 Nov, 2023, 13:29

I made a database in appwrite and in that database there are todos in that there are mainly three main category according to those category things will filter out with the help of map

Adnan Khan
17 Nov, 2023, 13:29

In chrome in console this is showing

Adnan Khan
17 Nov, 2023, 13:29

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://cloud.appwrite.io/v1/databases/655248ee50900f83353c/collections/65524a5470af0aafb0e9/documents. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 404.

Uncaught (in promise) AppwriteException: Network request failed AppwriteException sdk.js:82 call sdk.js:404 rejected sdk.js:23

D5
17 Nov, 2023, 16:49

@Adnan Khan Are you self-hosting appwrite?

Drake
17 Nov, 2023, 23:24

FYI, it's best to wrap code in backticks to format a bit nicer. You can use 1 backtick for inline code (https://www.markdownguide.org/basic-syntax/#code) and 3 backticks for multiline code (https://www.markdownguide.org/extended-syntax/#syntax-highlighting.

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